Create firewall rules
A firewall rule is a single line in a firewall group that accepts or drops a kind of incoming traffic: for example “accept TCP port 443 from anywhere”. Each rule says what to do (Action), which protocol and port it covers, and which addresses it applies to (Source). A rule applies to every VM attached to its group as soon as you save it.
When to use which rule
CIDR notation describes a range of addresses: the number after the slash says how many leading bits are fixed. 198.51.100.7/32 is exactly one address, 198.51.100.0/24 is the 256 addresses from 198.51.100.0 to 198.51.100.255, and 0.0.0.0/0 is every IPv4 address (the portal’s Anywhere).
How rules are applied
- Incoming traffic that no rule accepts is dropped. A group with no rules of yours lets nothing in.
- Order doesn’t matter between accept rules. If any accept rule matches, the traffic is let in.
- Drop beats accept. If a drop rule matches the traffic too, it is dropped, wherever the rules sit in the list.
- Replies are allowed automatically. Groups are stateful, so you never need rules for the return half of a connection, and outgoing traffic is allowed by a system rule.
Before you begin
- A firewall group. If you don’t have one, click Create Firewall Group on the Firewalls page. See Firewalls. The default group (marked (default)) can’t be edited.
- A verified organization. See Verify your identity.
- The ports your app uses and, for a Custom source, the addresses to allow. Your own public address is shown by searching “what is my IP” in a browser.
Add a rule
Open the group
In the sidebar, under Network & Security, click Firewalls, then click the group’s name. It opens on the IPv4 Rules tab, under Inbound IPv4 Rules.
Add a row
Click Add rule. A new row appears with these defaults:
Picking a common app fills in the protocol and port for you. ICMP and Any have no port.
Before you change or delete a rule for SSH (22) or RDP (3389), make sure another rule still lets you in. If you lock yourself out, attach the VM to a group that allows your address, or detach it to go back to the default group, which allows 22 and 3389.
Change or delete a rule
- Change: edit the row’s fields and click Save on that row. You see “Firewall rule updated.”
- Delete: click the delete icon on the row. The rule is removed at once, without a confirmation step, and you see “Firewall rule removed.”
- System rules (“Allow all outbound IPv4” and “Default deny all other inbound IPv4”) have no Save or delete controls and can’t be changed.
Example rule sets
A public web server, managed over SSH from one office:
A database that only two app servers may reach:
Add rules with the API
Inbound rule (the portal’s accept is allow in the API):
The API can also filter outbound traffic, which the portal doesn’t show. This rule stops the VMs from sending mail directly on port 25:
Change a rule with PATCH .../rules/RULE-ID (send only the fields to change; "enabled": false switches it off), or remove it with DELETE .../rules/RULE-ID. The token needs firewall.write.
Verify
From a computer outside IBEE (and outside the allowed addresses, to test a Custom source), check the port:
An accepted port connects at once. A dropped port gives up after the 5 seconds set by -w 5, because the firewall doesn’t answer. On Windows, use Test-NetConnection 203.0.113.10 -Port 443.
