firewalld Network Packet Filtering and Zones
In RHEL 9, firewalld is a dynamic firewall daemon that manages Linux packet filtering using nftables backend, categorizing network connections into security zones.
1. Zones Overview
public: Default zone for untrusted networks; only explicitly allowed incoming traffic is permitted.trusted: All incoming network packets are accepted.drop/block: Incoming packets are rejected or silently discarded.
2. Essential Commands for RHCSA
Inspecting State
# Check daemon status
firewall-cmd --state
# View default zone
firewall-cmd --get-default-zone
# List all open ports and enabled services in active zone
firewall-cmd --list-all
firewall-cmd --zone=public --list-all
Allowing Services and Ports
# Add HTTP service temporarily (in memory)
firewall-cmd --add-service=http
# Add HTTP and HTTPS persistently across reboots (--permanent)
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
# Open custom TCP port 8080 persistently
firewall-cmd --permanent --add-port=8080/tcp
# Reload running firewall to apply permanent changes without restarting
firewall-cmd --reload
[!TIP] Always verify firewall changes by running
firewall-cmd --reloadfollowed byfirewall-cmd --list-all. If you forget--permanent, rules vanish after reload!
Rich Rules for Advanced Filtering
# Allow SSH only from a specific management subnet (192.168.1.0/24)
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" service name="ssh" accept'
firewall-cmd --reload
Cross-references:
- See Network Configuration and Management with nmcli for network interface and connection profile management.
- See OSI Layer 4: Transport Layer for TCP and UDP port multiplexing fundamentals.