Set up a firewalld zone with rich rules for specific services
Firewalld lets RHEL, CentOS Stream and Fedora administrators apply policies to networks with different trust levels. Zones group settings, while rich rules limit a service to a particular source, port and protocol.
This example creates a business-services zone for an API on TCP 8443, a metrics endpoint on TCP 9100 and SSH. Each service is restricted to an office or VPN source range; other traffic meets the zone’s fallback policy.
Plan the interface assignment before changing active rules. Keep console access available, test from allowed and denied clients, and remember that an IPv4 rule does not cover IPv6. Firewalld does not enable NAT automatically.
The commands fit nftables-backed RHEL-family systems used across Australia and separate inbound filtering from forwarding or masquerading. They also fit local servers, cloud instances and managed gateways.
Plan the trust boundary
Decide what the zone represents. A corporate LAN may justify strict source filtering, while a guest network needs another zone. Do not use the built-in trusted zone for application traffic because its ACCEPT target permits traffic without source filtering.
Choose CIDRs from actual egress or VPN ranges. The 203.0.113.0/24 and 2001:db8:abcd::/48 values are documentation prefixes; replace them before applying the rules. A city name is not a firewall identity.
Create the zone and service definitions
Confirm firewalld is active and record the default zone and interfaces. This shows whether another zone owns the intended network.
sudo systemctl is-active firewalld
sudo firewall-cmd --get-default-zone
sudo firewall-cmd --get-active-zones
Create the zone and named services. Defining each port once keeps the policy readable and reusable across address families.
sudo firewall-cmd --permanent --new-zone=business-services
sudo firewall-cmd --permanent --zone=business-services --add-target=drop
sudo firewall-cmd --permanent --new-service=company-api
sudo firewall-cmd --permanent --service=company-api --add-port=8443/tcp
sudo firewall-cmd --permanent --new-service=node-metrics
sudo firewall-cmd --permanent --service=node-metrics --add-port=9100/tcp
sudo firewall-cmd --reload
Reload so the definitions become available. Do not add company-api as a broad zone service, because the rich rules provide source restriction.
Add source-specific rich rules
A rich rule combines an address family, source and service before an action. The service name resolves to the port defined earlier, keeping source-specific rules readable.
Add rules permanently and mirror them at runtime for testing; permanent changes do not affect the running firewall until a reload.
for service in company-api node-metrics ssh; do
rule="rule family=\"ipv4\" source address=\"203.0.113.0/24\" service name=\"$service\" accept"
sudo firewall-cmd --permanent --zone=business-services --add-rich-rule="$rule"
sudo firewall-cmd --zone=business-services --add-rich-rule="$rule"
done
Use the same pattern for node-metrics and ssh, then add IPv6 rules only if clients use the allocated prefix. Check for overlapping zone services, because a broader rule can defeat the restriction.
Bind the zone to the intended interface
Assign the interface through NetworkManager when it manages the profile, or use firewall-cmd when another tool owns it. Avoid defining the zone in both places, because a reconnect can restore the old assignment.
sudo nmcli connection modify "Office LAN" connection.zone business-services
sudo nmcli connection up "Office LAN"
With firewall-cmd as owner, use its permanent add-interface and runtime change-interface commands for ens192 instead.
If the host forwards traffic, configure masquerading or forwarding separately. Masquerading suits a routing gateway and does not expose a local API. Before moving production, confirm the SSH rule covers your administrator source; surviving sessions are not a rollback plan.
Verify access and preserve rollback
Inspect the runtime policy before moving the interface. A rule can be accepted yet remain ineffective if the port, source prefix or zone target is wrong.
sudo firewall-cmd --zone=business-services --list-rich-rules
sudo firewall-cmd --zone=business-services --list-all
After assignment, test from allowed and different sources. API and metrics connections should succeed only from the allowed path; the blocked test should time out or be rejected. Test SSH separately because a wrong source rule can cut remote administration.
nc -vz -w 5 app-server.example.test 8443
nc -vz -w 5 app-server.example.test 9100
Keep console access ready. If a rule misbehaves, remove the runtime rule or move the interface back, correct the configuration and retest. Do not reload first, because that activates unfinished permanent changes.
Audit traffic and configuration drift
Compare runtime and permanent views and retain rich-rule lists with change records. This exposes interface moves and stale ports during review.
sudo firewall-cmd --zone=business-services --list-rich-rules
sudo firewall-cmd --permanent --zone=business-services --list-rich-rules
sudo firewall-cmd --info-service=company-api
sudo firewall-cmd --info-service=node-metrics
The linked data logger example shows an application persisting records locally. That differs from firewall auditing: firewalld does not provide application logging or a SIEM pipeline, and packet logging must be enabled before the host logging stack forwards events.
Custom definitions live under /etc/firewalld/services and /etc/firewalld/zones. Review them after a reload because referenced services must remain valid. Management runs and upgrades can reveal drift from the intended policy.
Adapt the pattern for Australian operations
Australian deployments often place workloads in a Sydney or Melbourne cloud region while administrators in Brisbane or Perth connect through a VPN. The firewall sees the VPN or office egress address, so use stable prefixes rather than city names.
For customs workloads connected with Australian Border Force, use agency-approved gateways and documented partner CIDRs. Domain names alone are unsafe because they can resolve to different addresses. The Australian Signals Directorate’s Essential Eight guidance also supports explicit allow-lists and reduced exposure.
In the Australian market, teams may combine local administration with managed providers or cloud appliances, so record rule ownership and expiry. The publication explains its educational focus on its about Linuxtpoint page. Replace the example prefixes with the actual office egress and VPN ranges, then inspect firewall-cmd --zone=business-services --list-rich-rules before assigning the interface.