firewall-cmd.
Verify firewalld is running
Start by checking the systemd service and the firewalld runtime state:firewall-cmd --state returns running, the daemon is active and ready to accept commands.
Active zones and interfaces
List active zones to see which network interface(s) are bound to which zone:Show full zone configuration
To inspect all settings for the current (active or default) zone, use--list-all:
Adding and persisting services
Allow an existing service (for example, HTTP) at runtime only:--permanent updates configuration files but does not change the current runtime rules. Either add the non-permanent rule (without --permanent) to apply immediately, or reload persistent configuration into runtime:
Using
--permanent writes the rule to the configuration. To apply those persistent rules to the running firewall, run firewall-cmd --reload.Adding and persisting ports
Open a custom port (for example TCP 9294) at runtime:Adding sources to zones and blocking traffic
You can bind a specific IP source to a zone. For example, add a source to the default zone (runtime):block zone (runtime):
block zone rejects or drops packets according to that zone’s target. Verify zones and their sources:
When assigning sources to restrictive zones (for example
block), confirm the IPs are correct. Mistakenly blocking legitimate clients can cause loss of access.--permanent when adding a source, remember to --reload to apply it to the running firewall.
Removing rules
To remove a rule, replace--add-* with --remove-*. Examples:
- Remove an enabled service at runtime:
- Remove a persistent service and reload:
Rich rules
Firewalld rich rules provide advanced, expressive controls (logging, matching by source/protocol, forwarding, rate limiting, etc.). They are not required for the RHCSA exam but are extremely useful in production environments where you need fine-grained behavior. See firewalld rich rule examples in the official documentation for patterns and syntax.Quick reference — common firewall-cmd tasks
Summary
This demo covered essential firewalld tasks on RHEL:- Verifying firewalld status and runtime state
- Viewing active zones and their interfaces
- Inspecting zone configuration with
--list-alland--list-all-zones - Allowing services and ports at runtime and persisting them with
--permanent - Assigning sources to zones (including the
blockzone) and understanding targets - Removing rules and using
--reloadto apply persistent changes - A brief note about advanced rich rules
