Skip to navigation

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

You want to…ActionProtocolPort / AppSource
Serve a websiteacceptTCPHTTP (80) and HTTPS (443), one rule eachAnywhere
Let only your office use SSHacceptTCPSSH (22)Custom: your office’s address, for example 198.51.100.7/32
Let your app servers reach a databaseacceptTCPPostgreSQL (5432) or MySQL (3306)Custom: the app servers’ addresses
Answer pingacceptICMP—Anywhere
Block one abusive address completelydropAnyAll portsCustom: that address
Open a range of portsacceptTCP or UDPA range, for example 8000-9000Anywhere or Custom

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

  1. Incoming traffic that no rule accepts is dropped. A group with no rules of yours lets nothing in.
  2. Order doesn’t matter between accept rules. If any accept rule matches, the traffic is let in.
  3. Drop beats accept. If a drop rule matches the traffic too, it is dropped, wherever the rules sit in the list.
  4. 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

1

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.

2

Add a row

Click Add rule. A new row appears with these defaults:

ColumnDefaultOptions
Actionacceptaccept, drop
ProtocolTCPAny, TCP, UDP, ICMP. GRE, ESP and AH are listed but can’t be used yet.
Port / AppemptyCustom port (one port such as 22, or a range such as 8000-8080), All ports, or a common app: SSH (22), HTTP (80), HTTPS (443), MySQL (3306), PostgreSQL (5432), DNS (UDP) (53), MS RDP (3389)
SourceAnywhereAnywhere, Custom
CIDR/IP0.0.0.0/0With Custom, one or more addresses or CIDR ranges separated by commas
NotesemptyOptional, for example office SSH

Picking a common app fills in the protocol and port for you. ICMP and Any have no port.

3

Fill in the row

Choose the Action, Protocol and Port / App. For Source, keep Anywhere or choose Custom and type addresses in CIDR/IP, for example 198.51.100.7/32, 203.0.113.0/24.

4

Save the row

Click Save on the row. You see “Firewall rule added.” The rule now applies to every VM in the group. Each row is saved on its own; a row you haven’t saved isn’t applied.

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:

ActionProtocolPort / AppSource
acceptTCPHTTP (80)Anywhere
acceptTCPHTTPS (443)Anywhere
acceptTCPSSH (22)Custom: 198.51.100.7/32

A database that only two app servers may reach:

ActionProtocolPort / AppSource
acceptTCPPostgreSQL (5432)Custom: 203.0.113.10/32, 203.0.113.11/32
acceptTCPSSH (22)Custom: 198.51.100.7/32

Add rules with the API

Inbound rule (the portal’s accept is allow in the API):

curl -X POST "https://api.ibee.ai/v1/networking/firewall-groups/FIREWALL-GROUP-ID/rules?workspace_id=710995" \
-H "Authorization: Bearer $IBEE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"direction": "ingress",
"protocol": "tcp",
"port_start": 22,
"port_end": 22,
"remote_targets": ["198.51.100.7/32"],
"action": "allow",
"description": "office SSH"
}'

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:

curl -X POST "https://api.ibee.ai/v1/networking/firewall-groups/FIREWALL-GROUP-ID/rules?workspace_id=710995" \
-H "Authorization: Bearer $IBEE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"direction": "egress", "protocol": "tcp", "port_start": 25, "action": "drop", "remote_targets": ["0.0.0.0/0"]}'
FieldValuesDefault
directioningress (incoming) or egress (outgoing)ingress
protocoltcp, udp, icmp, anytcp
port_start, port_end1–65535. port_start is required for tcp and udp.port_end = port_start
remote_targetsIPv4 addresses or CIDR ranges["0.0.0.0/0"]
actionallow or dropallow

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:

nc -vz -w 5 203.0.113.10 443

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.

Limits

ItemLimit
Ports1–65535; one port or one range per rule
ProtocolsAny, TCP, UDP, ICMP
AddressesIPv4 only. The IPv6 Rules tab says “Coming soon”.
Rules per groupThe group page counts inbound rules out of 50
When a rule appliesAs soon as Save finishes
Check for a dropped port with nc -w 5Fails after 5 seconds

Troubleshooting

You seeWhat it meansWhat to do
”Firewall rule save failed”The row has a problem: no port for TCP or UDP, a port outside 1–65535, a range written wrongly, an empty CIDR/IP with a Custom source, or an invalid addressEnter a port such as 22 or a range such as 8000-8080, and addresses such as 198.51.100.7/32. Then click Save again.
”The current firewall API supports Any, TCP, UDP, and ICMP rules only.”You chose GRE, ESP or AHChoose Any, TCP, UDP or ICMP.
”System-managed rules cannot be removed here.”You tried to delete a system ruleSystem rules can’t be changed. Add your own rules instead.
A rule doesn’t seem to applyThe row wasn’t saved, or a drop rule also matchesClick Save on the row. Check for a drop rule covering the same traffic.
The port is accepted but the connection still failsThe firewall inside the VM blocks it, or the app isn’t listeningCheck sudo ufw status or sudo firewall-cmd --list-all, and sudo ss -tlnp.
A 500 error when adding or changing a TCP or UDP rule (API)The rule has no port_start, or port_end is lower than port_startAdd port_start, and make port_end the same or higher.
400 “System-managed firewall rules cannot be updated” (API)You tried to change a system ruleChange your own rules only.