No active firewall
- Check
net.firewall- Severity
- medium
- Runs
- on the server, in the daily run of the agent
- Looks at
- nftables or iptables rules loaded, ufw or firewalld active
What the check looks at
The agent checks whether ufw or firewalld is active, or whether the loaded nftables or iptables rules filter
incoming traffic: an input chain with the policy drop, or with drop or reject rules. The rules that Docker
loads for container traffic do not count, because they do not filter traffic to the services of the host.
Why it matters
Without a firewall, every service that listens on a public address is reachable from the internet. That is fine for SSH and a web server, but software often opens more: a database installed for a test, a metrics exporter, an admin panel. A default-deny firewall keeps those closed even when their configuration changes after an update. The check net.public_listeners lists what is listening.
How to fix it
Allow SSH before you turn on a default-deny policy, keep your SSH session open, and know how to reach the console of the server.
Ubuntu and Debian (ufw)
sudo apt install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp # only if the server runs a web server
sudo ufw enable
RHEL, Rocky Linux and AlmaLinux (firewalld)
sudo dnf install firewalld
sudo systemctl enable --now firewalld
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
The default zone public allows ssh, dhcpv6-client and cockpit.
Alpine (nftables)
The shipped /etc/nftables.nft drops incoming traffic but does not allow SSH. Add your ports in a file in
/etc/nftables.d/ first:
apk add nftables
cat > /etc/nftables.d/50-services.nft <<'EOF'
table inet filter {
chain input {
tcp dport 22 accept comment "SSH"
}
}
EOF
nft -c -f /etc/nftables.nft
rc-update add nftables
rc-service nftables start
On a Docker host, ports published by Docker pass through these rules (Docker adds its own). Publish them on
127.0.0.1 or filter them in the DOCKER-USER chain; see
Docker bypasses ufw.
How to check the fix
sudo ufw status verbose # ufw
sudo firewall-cmd --list-all # firewalld
sudo nft list ruleset # nftables
Then test from another machine: nc -vz <server-ip> <port> should connect for open ports and time out for the
rest.
When a warning is fine
When the server sits behind a network firewall of the provider (security groups, cloud firewall) that allows only the ports you need, and nobody can reach it from inside the same network. A host firewall still helps there, because the provider rules are easy to change by mistake and do not cover traffic from other servers in the same private network.