How to set up a firewall using FirewallD on RHEL 8

Setting up a firewall using FirewallD on Red Hat Enterprise Linux 8 (RHEL 8) is a fairly straightforward process. Here’s an overview of the steps you’ll need to take:

  1. Start by installing FirewallD by running the following command:
sudo dnf install firewalld
  1. Once the installation is complete, start the FirewallD service:
sudo systemctl start firewalld
  1. To make sure FirewallD starts automatically at boot time, run the following command:
sudo systemctl enable firewalld
  1. To check the status of the FirewallD service, you can run the following command:
sudo systemctl status firewalld
  1. The default firewall configuration is located in the /etc/firewalld/ directory. The main configuration file is firewalld.conf and the configuration files for individual zones are located in the /etc/firewalld/zones/ directory.
  2. To see the current firewall configuration, you can run the following command:
sudo firewall-cmd --list-all
  1. To add a service to the firewall, you can use the following command:
sudo firewall-cmd --add-service=http
  1. To add a port to the firewall, you can use the following command:
sudo firewall-cmd --add-port=80/tcp
  1. To remove a service or port from the firewall, you can use the following command:
sudo firewall-cmd --remove-service=http
  1. To reload the firewall configuration, you can use the following command:
sudo firewall-cmd --reload
  1. To check the rules in a zone, you can use the following command:
sudo firewall-cmd --list-all --zone=public

By following these steps, you should now have a working firewall configuration using FirewallD on your RHEL 8 system. You can now use the firewall-cmd command to configure and manage your firewall rules.

Leave a Comment