Secure the network with firewalld

firewalld is a set of scripts and a daemon that manage netfilter on your RHEL system. It aims at creating a simple command-line interface to manage the firewall on your systems.

How to do it…

By default, firewalld is included in the "core" rpm group, but it may not be installed for some reason (that you left it out of your kickstart would be one!). Perform the following steps:

  1. Install firewalld via the following command line:
    ~]# yum install -y firewalld
    
  2. Now, enable firewalld through the following:
    ~]# systemctl enable firewalld
    
  3. Finally, ensure that firewalld is started by executing the following command line:
    ~]# systemctl restart firewalld
    

Showing the currently allowed services and ports on your system

List all the allowed services using the following command:

~]# firewall-cmd –list-services

You can see the output as follows, where all the allowed services are listed:

Showing the currently allowed services and ports on your system

Now, show the tcp/udp ports that are allowed by your firewall using the following command:

~]# firewall-cmd --list-ports

Here's what the output should look like:

Showing the currently allowed services and ports on your system

Allowing incoming requests for NFS (v4)

Perform the following steps to allow NFSv4 traffic on your system:

  1. First, allow nfs traffic via this command:
    ~]# firewall-cmd --add-service nfs –-permanent
    success
    ~]#
    
  2. Then, reload the configuration as follows:
    ~]# firewall-cmd --reload
    success
    ~]#
    
  3. Now, check the newly applied rule by executing the following command line:
    ~]# firewall-cmd –-list-services
    nfs
    ~]#
    

Allowing incoming requests on an arbitrary port

Perform the following steps to allow incoming traffic on port 1234 over both tcp and udp:

  1. First, allow traffic on port 1234 over tcp and udp by running the following:
    ~]# firewall-cmd --add-port 1234/tcp --permanent
    success
    ~]# firewall-cmd --add-port 1234/udp --permanent
    success
    ~]#
    
  2. Reload the configuration by executing the following command:
    ~]# firewall-cmd –-reload
    success
    ~]#
    
  3. Check the newly applied rule via the following:
    ~]# firewall-cmd –-list-ports
    1234/tcp 1234/udp
    ~]#
    

There's more…

firewalld comes with a set of predefined port configurations, such as HTTP and HTTPS. You can find all such definitions in /lib/firewalld/services. When creating your own port definitions or modifying the existing ones, you should create new port definition files in /etc/firewalld/services.

When creating new "rules" by adding ports, services, and so on, you need to add the --permanent option, or your changes would be lost upon the rebooting of the system or the reloading of the firewalld policy.

See also

For more information on configuring your firewall, check the man pages for firewall-cmd(1).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset