A source assignment sends traffic from a specific address, network, MAC address, or ipset into a chosen firewalld zone. It is useful when one client network needs a different rule set from the interface's general zone, such as a partner API range or a management VPN pool.
The example assigns 10.77.0.0/24 to a custom trusted-api zone. The zone must contain the services, ports, rich rules, or policies that should apply to that source because the source binding only chooses the zone; it does not open traffic by itself.
Add the source to runtime for immediate effect and permanent configuration for persistence. Query both views before and after the change so a later reload does not move the source back to the default or interface-based zone.
Related: Create a firewalld zone
Related: Check active firewalld zones
Related: Create a firewalld ipset
$ sudo firewall-cmd --state running
$ sudo firewall-cmd --get-zones block dmz drop external home internal public trusted trusted-api work
Create the zone first if it is not listed.
Related: Create a firewalld zone
$ sudo firewall-cmd --zone=trusted-api --list-all trusted-api target: default icmp-block-inversion: no interfaces: sources: services: https ssh ports: protocols: forward: no masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
Do not bind a source to a zone until the zone's allowed services match the intended exposure for that source network.
$ sudo firewall-cmd --get-zone-of-source=10.77.0.0/24 no zone
$ sudo firewall-cmd --zone=trusted-api --add-source=10.77.0.0/24 success
$ sudo firewall-cmd --permanent --zone=trusted-api --add-source=10.77.0.0/24 success
$ sudo firewall-cmd --check-config success
$ sudo firewall-cmd --reload success
$ sudo firewall-cmd --zone=trusted-api --query-source=10.77.0.0/24 yes
$ sudo firewall-cmd --permanent --zone=trusted-api --query-source=10.77.0.0/24 yes
$ sudo firewall-cmd --get-active-zones trusted-api sources: 10.77.0.0/24 public (default) interfaces: enp1s0
$ nc -vz app01.example.net 443 Connection to app01.example.net 443 port [tcp/https] succeeded!
If the test fails, confirm the client source as seen by the server and inspect the target zone's services, ports, and rich rules.