firewalld in practice: the runtime vs permanent two-layer model measured (an 8443 case)
What you will learn
Section titled “What you will learn”firewalld’s single core difficulty: the two layers of runtime (running) and permanent (persistent). This page nails both layers with a complete 8443 measurement; everything else is combinations.
First, the default state
Section titled “First, the default state”firewall-cmd --state # runningfirewall-cmd --get-active-zonesfirewall-cmd --list-allpublic (default, active) interfaces: ens18 services: cockpit dhcpv6-client sshOL 10 defaults: a single public zone allowing cockpit (9090), dhcpv6-client and ssh. Traffic from interfaces without their own binding enters the default zone.
The two-layer model: the 8443 case measured
Section titled “The two-layer model: the 8443 case measured”# 1. Write only the persistent layerfirewall-cmd --permanent --add-port=8443/tcp# success
# 2. Query the runtime — not there!firewall-cmd --query-port=8443/tcp# no ← permanent changes do not enter runtime
# 3. Reload pours the persistent layer into the runtimefirewall-cmd --reloadfirewall-cmd --query-port=8443/tcp# yes ← effective now
# 4. Cleanup (remove from both layers)firewall-cmd --permanent --remove-port=8443/tcp && firewall-cmd --reloadThe measured comparison:
| Action | Immediate | Survives reboot |
|---|---|---|
--add-* (without —permanent) | ✅ | ❌ |
--permanent --add-* | ❌ (needs reload) | ✅ |
--permanent --add-* + --reload | ✅ | ✅ |
runtime change + --runtime-to-permanent | ✅ | ✅ |
Workflow suggestion: experiment in runtime, then persist once with firewall-cmd --runtime-to-permanent once verified — handier than pairing —permanent + reload every time.
Common operations
Section titled “Common operations”# Service sets (predefined, e.g. http/https/ssh)firewall-cmd --add-service=http --permanentfirewall-cmd --remove-service=http --permanent
# Ports (when no predefined service exists)firewall-cmd --add-port=8443/tcp --permanent
# Rich rule (fine-grained rules with a source qualifier)firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=192.168.50.0/24 port port=5432 protocol=tcp accept'
# Troubleshooting: the current state of a portfirewall-cmd --query-port=8443/tcpfirewall-cmd --list-ports --permanentThe division of labor with SELinux
Section titled “The division of labor with SELinux”The troubleshooting order for an unreachable port: ss confirms listening → firewalld confirms allowance → SELinux confirms permission (semanage port -l | grep <port>; a service binding a non-default port gets stopped by SELinux too — see the SELinux page). Each of the three layers owns one segment; do not guess across them.
Evidence and limits on this page
Section titled “Evidence and limits on this page”- Measured: the default zone/service list, http add/remove, and the full two-layer 8443 chain (E3);
- Not measured: panic/emergency modes and ipset set rules (advanced scenarios);
- Sources:
firewall-cmd(1), firewalld official documentation, OL10 security documentation.