Security
Host firewall
Reusable nftables rule sets that CloudOps applies on your Linux servers, and how they relate to security groups.
What it is
A host firewall policy is a named list of firewall rules. CloudOps writes the rules into the nftables firewall of every server you assign the policy to. One policy can be assigned to many servers, and a server can have several policies.
Policies live under Security → Host Firewall. Each server and VM page also has a Host Firewall tab that shows the rules in force on that machine.
How it relates to security groups
Security groups, under Networking → Security Groups, and host firewall policies write into the same CloudOps firewall table on a server. Which one decides depends on the machine:
- A bare-metal server with no host firewall policy takes its rules from its security groups.
- A bare-metal server with one or more host firewall policies takes the rules for its own traffic from those policies only. Its security groups are no longer pushed to it. VMs running on that server still get the rules of their own security groups.
- A VM has its security groups enforced on the server that hosts it, before traffic reaches the VM. A host firewall policy assigned to the VM runs inside the VM. Traffic has to pass both.
A security group's server list has an Enforcement column that says, for each member, whether CloudOps enforces the group there. See Networking for security groups.
A server with policies keeps them when CloudOps pushes its firewall for another reason, such as creating a VM on it, or turning the office VPN on or off when it is a VPN gateway.
The firewall engine
CloudOps pushes security groups and policies to a server only when its firewall engine is nftables. The top of the Host Firewall tab shows the engine, who chose it, what the last firewall check found and why, and says when nothing CloudOps stores for the server reaches it.
- Detected on the server: nftables is running, or nftables cannot take over and the engine is iptables.
- Chosen by CloudOps: nftables is installed but was not running, as on a fresh Ubuntu server, and no other software has firewall rules on the server. Starting nftables clears every other firewall rule on a server, so a server running Docker, Kubernetes, libvirt, ufw or firewalld stays on iptables, and the tab names what would have been cleared. Nothing is pushed to such a server until it is in a security group or has a policy.
- Set by an admin: an admin pressed Change engine. CloudOps never changes this choice itself.
Changing the engine pushes the server's firewall again at once. Switching to nftables blocks every inbound service that SSH, the server's security groups and its policies do not allow, and the first start of nftables clears the other firewall rules on the server. The rules of the previous engine are not removed. Check both before you switch.
Who can do what
Members and above can create, change and delete policies and assign them to servers. Viewers can look at them. The built-in policies, marked System, cannot be edited or deleted, and their rules cannot be added, changed or removed.
Built-in policies
- Web Server: SSH (22), HTTP (80) and HTTPS (443) from anywhere.
- Database: SSH (22) from anywhere, and PostgreSQL (5432) and MySQL (3306) from
10.0.0.0/8. - SSH Only: SSH (22) from anywhere.
1. Create a policy
Open Security → Host Firewall and press Create Policy. Enter a Name, which no other policy may use, and an optional Description, then press Create policy.
2. Add rules
On the policy's page, choose Inbound Rules or Outbound Rules and press Add Rule:
- Quick Presets fill in common services: SSH, HTTP, HTTPS, MySQL, PostgreSQL, Redis, MongoDB, DNS, ICMP and All Traffic.
- Direction, and Protocol: TCP, UDP, ICMP or Any.
- Port Range: one port, such as
443, or one range, such as8000-8090. A list of ports is not accepted; add a rule for each. - Source and Destination: an IPv4 address or range, such as
203.0.113.0/24.0.0.0.0/0means anywhere. - Action: Allow or Deny.
- Position: the rule's place in the list.
- Description (optional): up to 256 characters, without quotes, backslashes or line breaks.
Adding, changing or deleting a rule pushes the policy again to every server that has it.
3. Assign it to servers
On the policy's page, under Assigned Servers, pick a server from Add a server... and press Add. You can also do it from a server's Host Firewall tab, with Add policy... and Add. CloudOps pushes the rules straight away, and the server's firewall status shows managed.
CloudOps pushes policies over SSH to Linux servers it manages, as nftables rules. A policy can be assigned only to a server whose firewall engine is nftables or Open vSwitch (see The firewall engine above). On any other server the assignment is refused, and the message says why and how to switch the engine. A Windows VM cannot be given a policy: its Host Firewall tab shows the Windows Firewall, which CloudOps sets from the VM's security groups.
How the rules are applied
- Always allowed in. Replies to existing connections, loopback traffic, ICMP and SSH on port 22 are always accepted, ahead of your rules. On a VPN gateway the VPN ports are too. A Deny rule therefore cannot block SSH, and a Deny rule for ICMP is refused.
- Inbound. Rules are checked in order, and the first rule that matches decides. On a server CloudOps built, inbound traffic that no rule allows is dropped. On a server you imported, it is let through, so only Deny rules change anything there.
- Outbound. Everything is allowed unless a Deny rule matches, so an outbound rule must be a Deny; an outbound Allow is refused.
- What a rule matches. Inbound rules match on the Source, and outbound rules on the Destination; the other field is not used. A Deny rule needs a port, or protocol Any with a specific address. An inbound Allow rule needs a port or a specific source, except an Allow for Any protocol from anywhere, which opens the server to all inbound traffic. A port needs protocol TCP or UDP. CloudOps refuses a rule that does not meet this, and the rule form says why before you save.
- Several policies on one server are merged into one list. The order between policies is not guaranteed, so do not rely on a Deny in one policy to override an Allow in another.
- Safe swaps. CloudOps checks the new rules before it loads them and swaps them in all at once. If the server rejects them, the rules it already had stay in place.
- IPv4 only. Rules match IPv4 addresses; an IPv6 address is refused.
The Host Firewall tab
On a server or VM page, the Host Firewall tab shows:
- Firewall engine: the engine, who chose it and why, and, for admins, Change engine. See The firewall engine above.
- Policies: the assigned policies. Click one to open it, or its × to remove it from the server.
- The rules in force, under All, Input, Output and Forward. Each rule says where it comes from: Base for the always-allowed rules, a policy's name, or Server for a rule found on the server that CloudOps does not manage.
- Sync Rules, which reads the server's firewall again. CloudOps also does this on its own about every 3 hours. Reading it does not push any rules, but it can move the server to nftables as described above.
- Security Recommendations, such as SSH or a database port open to all sources, or an Allow and a Deny for the same port.
- Traffic Flow, with packet counts per rule. Press Refresh to collect new counts.
Adopt the rules a server already has
When CloudOps finds firewall rules on a server that it does not manage, the status shows pending_review and the tab offers Import Detected as Policy. Give the policy a name and press Import & Apply. CloudOps creates a policy from the rules it can represent exactly, assigns it to the server and pushes it. Like an assignment, this is refused on a server whose firewall engine is not nftables or Open vSwitch.
Rules that match on an interface, an ipset, a connection state or a source port, or that jump to another chain, are left out, and the new policy's description says how many. Review the policy before you rely on it. If none of the rules can be represented, the import is refused.
Remove or delete a policy
- Removing a policy from a server pushes the server's remaining policies. If you remove the last one, CloudOps pushes the server's security group rules to it straight away. A server in no security group is left with the always-allowed rules alone, so on a server CloudOps built other inbound traffic is dropped; a server whose engine CloudOps chose by itself is opened again instead. Later security group changes reach the server only if CloudOps enforces security groups there: see the group's Enforcement column and the server's firewall engine.
- Deleting a policy is refused while servers use it, and the message names them. Remove the policy from those servers first, which pushes their new rules, then delete it.
The Audit button on a policy opens its entries in the audit log, including every rule added, changed or removed.