5.8. Using Zones to Manage Incoming Traffic Depending on Source You can use zones to manage incoming traffic based on its source. That enables you to sort incoming traffic and route it through different zones to allow or disallow services that can be reached by that traffic. If you add a source to a zone, the zone becomes active and any incoming traffic from that source will be directed through it. You can specify different settings for each zone, which is applied to the traffic from the given sources accordingly. You can use more zones even if you only have one network interface. 5.8.1. Adding a Source To route incoming traffic into a specific source, add the source to that zone. The source can be an IP address or an IP mask in the Classless Inter-domain Routing (CIDR) notation. To set the source in the current zone: To set the source IP address for a specific zone: The following procedure allows all incoming traffic from 192.168.2.15 in the trusted zone: List all available zones: Add the source IP to the trusted zone in the permanent mode: Make the new settings persistent: 5.8.2. Removing a Source Removing a source from the zone cuts off the traffic coming from it. List allowed sources for the required zone: Remove the source from the zone permanently: Make the new settings persistent: 5.8.3. Adding a Source Port To enable sorting the traffic based on a port of origin, specify a source port using the --add-source-port option. You can also combine this with the --add-source option to limit the traffic to a certain IP address or IP range. To add a source port: 5.8.4. Removing a Source Port By removing a source port you disable sorting the traffic based on a port of origin. To remove a source port: 5.8.5. Using Zones and Sources to Allow a Service for Only a Specific Domain To allow traffic from a specific network to use a service on a machine, use zones and source. The following procedure allows only HTTP traffic from the 192.0.2.0/24 network while any other traffic is blocked. Warning When you configure this scenario, use a zone that has the default target. Using a zone that has the target set to ACCEPT is a security risk, because for traffic from 192.0.2.0/24 , all network connections would be accepted. List all available zones: Add the IP range to the internal zone to route the traffic originating from the source through the zone: Add the http service to the internal zone: Make the new settings persistent: Check that the internal zone is active and that the service is allowed in it: 5.8.6. Configuring Traffic Accepted by a Zone Based on Protocol You can allow incoming traffic to be accepted by a zone based on the protocol. All traffic using the specified protocol is accepted by a zone, in which you can apply further rules and filtering. Adding a Protocol to a Zone By adding a protocol to a certain zone, you allow all traffic with this protocol to be accepted by this zone. To add a protocol to a zone: Note To receive multicast traffic, use the igmp value with the --add-protocol option. Removing a Protocol from a Zone By removing a protocol from a certain zone, you stop accepting all traffic based on this protocol by the zone. To remove a protocol from a zone:

Commands:
~]# firewall-cmd --add-source=<source>
~]# firewall-cmd --zone= zone-name --add-source=<source>
~]# firewall-cmd --get-zones
~]# firewall-cmd --zone=trusted --add-source= 192.168.2.15
~]# firewall-cmd --runtime-to-permanent
~]# firewall-cmd --zone= zone-name --list-sources
~]# firewall-cmd --zone= zone-name --remove-source=<source>
~]# firewall-cmd --runtime-to-permanent
~]# firewall-cmd --zone= zone-name --add-source-port=<port-name>/<tcp|udp|sctp|dccp>
~]# firewall-cmd --zone= zone-name --remove-source-port=<port-name>/<tcp|udp|sctp|dccp>
~]# firewall-cmd --get-zones block dmz drop external home internal public trusted work
~]# firewall-cmd --zone=internal --add-source=192.0.2.0/24
~]# firewall-cmd --zone=internal --add-service=http
~]# firewall-cmd --runtime-to-permanent
~]# firewall-cmd --zone=internal --list-all internal (active) target: default icmp-block-inversion: no interfaces: sources: 192.0.2.0/24 services: dhcpv6-client mdns samba-client ssh http
~]# firewall-cmd --zone= zone-name --add-protocol= port-name / tcp|udp|sctp|dccp|igmp
~]# firewall-cmd --zone= zone-name --remove-protocol= port-name / tcp|udp|sctp|dccp|igmp