To set up a firewall using FirewallD on RHEL 8, you will need to install and enable the firewalld service.
firewalld by running the following command:sudo dnf install firewalld
firewalld service to start at boot time:sudo systemctl enable firewalld
firewalld service:sudo systemctl start firewalld
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.
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
sudo firewall-cmd --reload
You can use the firewall-cmd command with various other options to further configure the firewall as needed.