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:
- Start by installing FirewallD by running the following command:
sudo dnf install firewalld
- Once the installation is complete, start the FirewallD service:
sudo systemctl start firewalld
- To make sure FirewallD starts automatically at boot time, run the following command:
sudo systemctl enable firewalld
- To check the status of the FirewallD service, you can run the following command:
sudo systemctl status firewalld
- 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.
- To see the current firewall configuration, you can run the following command:
sudo firewall-cmd --list-all
- To add a service to the firewall, you can use the following command:
sudo firewall-cmd --add-service=http
- To add a port to the firewall, you can use the following command:
sudo firewall-cmd --add-port=80/tcp
- To remove a service or port from the firewall, you can use the following command:
sudo firewall-cmd --remove-service=http
- To reload the firewall configuration, you can use the following command:
sudo firewall-cmd --reload
- 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.