Firewalls, SELinux, and service reachability
Most of the time lost configuring a service on the RPM family is not spent on the service. It is spent on a firewall that never opened the port, and a security label that blocked the daemon after the firewall let the packet through. This guide establishes the starting state of both, on both families, so every later page can say which barrier it is dealing with.
Start Here Guide 2 of 29 Intermediate
- PlatformsUbuntu 26.04 LTS + AlmaLinux 10.2
- Block devicesone 50 GB disk
- TimeAbout 15 min
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| LPIC2-A01 | 192.168.0.78 | Ubuntu 26.04 LTS | Primary service host - BIND, Apache, Samba, Postfix. Topic 204 RAID runs on loop devices; this machine has no spare disk | 2 Core | 4 GB | 50 GB |
| LPIC2-B01 | 192.168.0.79 | AlmaLinux 10.2 | Second service host - nginx, NFS, DNS secondary, and the other family's spelling of each service | 2 Core | 4 GB | 50 GB |
| LPIC2-C01 | 192.168.0.80 | Ubuntu 26.04 LTS | Client - resolves, mounts and connects, so every service is proven from a machine that is not running it | 2 Core | 4 GB | 50 GB |
This guide includes
Use this before configuring any service on the RPM family. This matters because the time lost is rarely spent on the service - it goes on the firewall, and on SELinux, which does not announce itself.
- finding two firewalls in opposite states, because the families do not start from the same place
- meeting the second barrier, which the firewall never mentions
- separating reachability from trust, from the client's side
Before you start
- what-lpic-2-asks
-
Two firewalls, in opposite states
The families do not start from the same place.
bash Example session sudo -n ufw status 2>/dev/null | head -3; echo "--- Debian-family firewall"Status: inactive--- Debian-family firewallsudo -n firewall-cmd --state 2>/dev/null; sudo -n firewall-cmd --get-default-zone 2>/dev/null; sudo -n firewall-cmd --list-services 2>/dev/nullrunningpubliccockpit dhcpv6-client sshExpected result
Status: inactiveon the Debian host; on the RPM hostrunning, default zonepublic, and servicescockpit dhcpv6-client ssh.Success conditionYou know which host will silently drop your traffic.
-
The second barrier, which the firewall does not tell you about
SELinux is enforcing, and it blocks things the firewall permitted.
bash Example session getenforce; echo "--- and SELinux, which blocks services the firewall let through"Enforcing--- and SELinux, which blocks services the firewall let throughExpected result
Enforcing.Success conditionYou know to check labels as well as ports.
-
The client can reach both servers, and cannot log into them
Reachability and trust are separate questions.
bash Example session getent hosts lpic2-a01 2>&1 | tail -1; echo "exit $? - resolved by the search domain, not /etc/hosts"192.168.0.78 lpic2-a01.practicelabpro.localexit 0 - resolved by the search domain, not /etc/hostsfor h in 192.168.0.78 192.168.0.79; do ping -c1 -W2 $h >/dev/null 2>&1 && echo "$h reachable" || echo "$h UNREACHABLE"; done192.168.0.78 reachable192.168.0.79 reachablessh -o BatchMode=yes -o ConnectTimeout=5 192.168.0.78 'echo reached; hostname' 2>&1 | tail -2; echo "--- key auth between lab hosts is NOT configured, and that is deliberate"Host key verification failed.--- key auth between lab hosts is NOT configured, and that is deliberateExpected resultThe name resolving through the search domain, both servers reachable, and
Host key verification failedwhen the client tries to SSH.Success conditionYou know what the client can and cannot do before any service exists.
Troubleshooting
A service is configured correctly and a client still cannot reach it.
Why: There are three barriers, not one: the service's bind address, the firewall, and on the RPM family SELinux - which announces nothing.
Fix:Check in that order.
ss -ltnpfor the bind address,ufw statusorfirewall-cmd --list-allfor the firewall, thengetenforceand a permissive-mode test.The same service works on the Debian host and is refused on the RPM one.
Why: The families do not start from the same place - ufw is inactive by default while firewalld is running, and SELinux is enforcing.
Fix:Never assume the two hosts are equivalent.
ufw statusreporting inactive andfirewall-cmd --list-allreporting a zone with few services is the normal starting difference.A host answers ping and refuses ssh, and the network is blamed.
Why: Reachability and trust are separate questions - ICMP proves the route, not that you may log in.
Fix:Separate them:
pingfor the path,nc -vz <host> 22for the port, then the authentication error itself. Each answers a different layer.