Sub topic 7
Firewall and network tooling differences
This chapter assumes you can use a shell, understand IP addresses and ports, and know that a firewall filters network traffic. It also assumes you have basic familiarity with systemd services and package managers. The goal is to compare the tools you are likely to meet on Ubuntu Server, Debian, and Rocky Linux without confusing a firewall with the network service that configures an interface.
Separate the layers
A server’s network behavior comes from several layers:
- The network manager configures interfaces, addresses, routes, and DNS.
- The kernel networking stack moves packets.
- A firewall filters packets and connections.
- A service, such as SSH or nginx, listens on a port.
A firewall rule cannot make a service listen. Conversely, a service can be listening locally while the firewall blocks remote clients.
Ubuntu Server commonly uses Netplan as a configuration layer. Netplan usually generates configuration for systemd-networkd on minimal servers, although NetworkManager can also be used. Debian often uses /etc/network/interfaces, systemd-networkd, or NetworkManager, depending on how it was installed and configured. Rocky Linux commonly uses NetworkManager and the nmcli command.
Firewall front ends
The Linux kernel provides packet-filtering facilities through the Netfilter subsystem. Administrators usually work through a higher-level tool rather than writing low-level rules directly.
Ubuntu commonly presents UFW, the uncomplicated firewall, as a simple front end. Debian does not enable a firewall front end by default, so an administrator may choose nftables, UFW, or another tool. Rocky Linux commonly uses firewalld. Firewalld manages nftables rules on current systems and organizes rules into zones.
| Distribution | Common front end | Typical configuration style |
|---|---|---|
| Ubuntu Server | UFW | Allow or deny ports and application profiles |
| Debian | None enabled by default | Choose and configure nftables, UFW, or another tool |
| Rocky Linux | firewalld | Assign interfaces to zones and add services or ports |
The front end matters because commands, persistence, and rule organization differ. Avoid managing the same host with multiple competing front ends. For example, adding rules manually with nft while also expecting firewalld to own the rules can make later troubleshooting difficult.
Allow SSH before enabling a firewall
When connecting remotely, allow SSH before enabling or reloading restrictive rules. Keep an existing session open while testing a new policy. Use a second session to confirm that the intended access still works.
# Ubuntu: inspect the current policy and allow SSH
sudo ufw status verbose
sudo ufw allow 22/tcp
sudo ufw enable
sudo ufw status numbered
# Rocky Linux: allow the predefined SSH service
sudo firewall-cmd --state
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
sudo firewall-cmd --list-services
# Debian with nftables: inspect active rules, if nftables is configured
sudo nft list rulesetUFW’s allow 22/tcp rule permits TCP traffic to port 22. Firewalld’s ssh service represents the same common use case, but it refers to a predefined service definition. A service definition can include ports and protocols without requiring you to remember each port.
Network inspection tools
The same diagnostic questions apply on all three distributions:
- Which interfaces exist?
- Which addresses and routes are configured?
- Which process is listening?
- Is DNS working?
- Is a firewall dropping the traffic?
The ip command is the modern common tool for addresses, links, and routes. The ss command displays sockets and listening services.
ip address
ip route
ss -lntup
getent hosts example.comOn Rocky Linux, nmcli device status and nmcli connection show reveal NetworkManager’s view of devices and connection profiles. On Ubuntu, netplan get can show Netplan’s configuration when Netplan is installed. On Debian, inspect the active network manager rather than assuming one layout.
# Rocky Linux
nmcli device status
nmcli connection show
# Ubuntu Server with Netplan
netplan getDo not treat a successful ping as proof that an application works. ICMP may be blocked while TCP is allowed, or the application may fail after the TCP connection because of TLS, authentication, or DNS configuration.
A practical troubleshooting path
Use this order when a client cannot reach a service:
- Confirm that the service is running and listening with
systemctl statusandss. - Confirm that the service listens on the expected address, not only on
127.0.0.1. - Check the local route and interface with
ip addressandip route. - Check the distribution’s firewall front end.
- Check upstream controls, such as a cloud security group or network firewall.
- Test DNS and the application protocol separately.
Exercise
Exercise
You administer a Rocky Linux server remotely over SSH. Which command adds the predefined SSH service to firewalld permanently, and which command applies the change?
Show answer
Use sudo firewall-cmd --permanent --add-service=ssh, then use sudo firewall-cmd --reload.