Skip to main content

Configure firewall rules

Firewall rules determine which traffic the router passes through its port in a network. A saved rule takes effect only after you click Apply rules or restart the router.

Before you begin​

  • You need the Cluster master role, or you must be the VDC admin who created the router.
  • The router is connected to the network that the rule is for — Create a router and connect networks to it.
  • To apply rules, the router must have the Started status.
  • You know the source and destination addresses and the destination port, for example traffic from 198.51.100.0/24 to 192.0.2.20 on port 22.

1. Add a rule​

  1. In the left menu, select Virtual Data Centers → the VDC → Edges, and click the router row in the Edges table. The router page opens.
  2. Click Add rule in the header of the Firewall rules section. The Firewall rule <N> block appears.
  3. Select Pass or Block in the Action field. The default is Block.
  4. Select In or Out in the Direction field.
  5. In the Network field, select the network of the router port that the traffic goes through.
  6. Select the protocol in the Protocol field: TCP, UDP, ICMP, or IP for any protocol. The default is TCP.
  7. Enter the addresses in the From (CIDR) and Dst. (CIDR) fields, for example 198.51.100.0/24 and 192.0.2.20/32. 0.0.0.0/0 means any address.
  8. Enter the destination port in the Dst. Port field, for example 22. 0 means any port.
  9. Click Save Rule. The web interface shows Firewall rule was successfully added!, and the rule appears in the section table.

In is traffic that comes to the router from the selected network through its port. Out is traffic that the router sends to this network. The router automatically passes replies to an allowed connection; they do not need a separate rule.

The router checks rules in ascending order of the "#" number, and the last matching rule applies. Make the first rule — the one with the lowest number — Block for any traffic, then add allow rules with higher numbers — Routers.

2. Apply the rules​

  1. Click Apply rules at the bottom of the router page. Center sends all saved firewall and NAT rules to the router.

The button is unavailable while the router does not have the Started status or is still booting.

Check the result​

The web interface shows a notification that the rules were applied successfully. Check the traffic that the rule describes: for example, connect over SSH to 192.0.2.20 from an address in 198.51.100.0/24.

If the rule does not take effect, check that you clicked Apply rules after saving. In the rules table, the web interface shows 0.0.0.0/0 and port 0 as Any.

View blocked traffic​

The router records the packets that Block rules with the Log check box have blocked. You can get them only from a router in the Started status.

  1. Open the Logs tab on the router page.
  2. In the Limit field, enter how many packets to get. An empty field means 1000. The router returns no more than 3000 at a time.
  3. Select the period in the Period field. An empty field means the whole log.
  4. Click Get file, then Download. The log.pcap file is downloaded: open it in Wireshark or tcpdump.

If there are no packets for the period, the web interface shows No data found. Try another params.

More​

  • "#" — the rule number, from 100 to 32767. The web interface suggests a number 100 higher than the largest one.

  • Log — the router logs the traffic that the rule blocks. The check box is available only for the Block action. How to view the logged traffic — View blocked traffic.

  • To delete a rule, click the trash icon in the rule row, and then click Delete in the confirmation window. A deleted rule stops taking effect after you click Apply rules.

Next​

API methods: edge-add-fw-rule, edge-remove-fw-rule, edge-list-rules, edge-deploy-rules, edge-get-pfloggs — in the API reference.