How to set up a firewall using FirewallD on RHEL 8

How to set up a firewall using FirewallD on RHEL 8

To set up a firewall using FirewallD on RHEL 8, you will need to install and enable the firewalld service.

  1. Install firewalld by running the following command:
refe‮r‬ to:lautturi.com
sudo dnf install firewalld
  1. Enable the firewalld service to start at boot time:
sudo systemctl enable firewalld
  1. Start the firewalld service:
sudo systemctl start firewalld
  1. To view the current firewall configuration, you can use the firewall-cmd command with the --list-all option:
sudo firewall-cmd --list-all

This will show the default firewall rules, which allow all incoming and outgoing traffic.

  1. To modify the firewall configuration, you can use the firewall-cmd command with various options. For example, to block incoming traffic from a specific IP address, you can use the --add-rich-rule option:
sudo firewall-cmd --add-rich-rule='rule family="ipv4" source address="1.2.3.4" reject'

To allow incoming traffic on a specific port, you can use the --add-port option:

sudo firewall-cmd --add-port=80/tcp

To make the changes permanent, you will need to run the --permanent option:

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="1.2.3.4" reject'
sudo firewall-cmd --permanent --add-port=80/tcp
  1. To apply the changes, you will need to reload the firewall:
sudo firewall-cmd --reload

You can use the firewall-cmd command with various other options to further configure the firewall as needed.

Created Time:2017-10-16 14:38:50  Author:lautturi