
It’s also possible to create some new ones, and it’s just as easy.
FIREWALLCMD PANIC MODE HOW TO
Until now, we only saw how to modify existing zones. In the same way, to remove a port we would do: # firewall-cmd -permanent -zone=external -remove-port=139/tcp To verify that the port has been added to the zone: # firewall-cmd -zone=external -list-ports But what if we want to add a specific port instead of service? The syntax would slightly change: # firewall-cmd -permanent -zone=external -add-port=139/tcp The syntax is very intuitive and doesn’t need any further explanation. If we want to make the reverse operation, and so remove a service from a zone, we would execute: # firewall-cmd -permanent -zone=external -remove-service=samba Permanent modifications will need a firewall reload to become effective. To make a persistent modification to a zone we must use the -permanent option: # firewall-cmd -permanent -zone=external -add-service=samba Then we check again the services allowed in the external zone: # firewall-cmd -zone=external -list-servicesĪs you can see, the only service allowed in the external zone is ssh. First we reload the service: # firewall-cmd -reload However, modifications made this way are temporary and won’t survive a reboot of the firewalld daemon. The result of the command clearly means that the samba service has been added to the zone. To verify it, let’s check the zone services: $ sudo firewall-cmd -zone=external -list-servicesĪs you can see we used the -list-services option for the purpose. The firewalld daemon responded with success, that means that the execution was successfull. Let’s say that we want to add the samba service to the external zone, all we would do is: # firwall-cmd -zone=external -add-service=samba Using services we can avoid having to remember specific ports each time. For example: the ssh service will include the TCP port 22, while the samba service will comprehend the set of ports 139 and 445 TCP and 137 and 138 UDP. First of all services are a preconfigured set of ports associated with specific protocol. Now let’s see how we can add or remove services or ports to a specific zone. Say for example we want to set the external zone as the default: # firewall-cmd -set-default=external

We may want to change what the default zone is.

For example, to retrieve information about the external zone, we would run: # firewall-cmd -zone=external -list-allĪs said before, when using the firewall-cmd tool, if no zone is specified, the default one is referenced. If we want to retrieve information about a specific, non-default zone, we should pass the zone name as an argument to the -zone option. Among the other things you can clearly see what network interfaces are associated with this zone (ens5f5 in this case) and what services are allowed (ssh, mdns, dhcpv6-client) in it. The command returned a summary of the state of the zone (in this case the default one, “public”). If a zone is not explicitly passed to the command, the default zone will be queried: # firewall-cmd -list-all If we want to have a list of all services associated with a zone we can run firewall-cmd with the -get-services option. Each interface is then configured with some exceptions, depending on the services that must be allowed. Their name is quite indicative of their purpose, but we need to know what services and ports are available through them: the general default rule is that every service or port are denied. I am running on a Fedora 27 system, let’s check what the available zones are: $ firewall-cmd -get-zonesįedoraServer FedoraWorkstation block dmz drop external home internal public trusted workĪs you can see, the above command returns a list of all available interfaces in my system. Usually firewalld comes with a set of preconfigured zones: to list this zones, and more generally to interact with the firewall, we will use the firewall-cmd utility. Zones can be associated with one or more network interfaces. A firewall based on zonesįirewalld is a zone-based firewall: each zone can be configured to accept or deny some services or ports, and therefore with a different level of security. In this tutorial we will learn more about it, and how to interact with it using the firewall-cmd utility. One of its more distinctive traits is its modularity: it works on the concept of connection zones. Since version 7 of Rhel and CentOS and version 18 of Fedora, firewalld is the default firewall system.
