Back to Notes
rhcsaNODE: #rhcsa-firewalld-packet-filtering

firewalld Network Packet Filtering and Zones

Managing network traffic filtering, zones, services, ports, rich rules, and persistent reloading using firewalld and firewall-cmd in RHEL 9.

AKA:firewalld, firewall-cmd, firewall zones, packet filtering
#rhcsa#redhat#linux#security#firewalld#networking#rhel9#sysadmin

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 --reload followed by firewall-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: