Configuring Firewall Rules with Firewalld CentOS RHEL ?

Here's a step-by-step guide on how to configure firewall rules with Firewalld on RHEL (Red Hat Enterprise Linux) 8:


1. Install Firewalld (if not already installed):

   sudo dnf install firewalld

2. Enable and start the Firewalld service:

   sudo systemctl enable firewalld

   sudo systemctl start firewalld

3. Check the status of the Firewalld service:

   sudo systemctl status firewalld

   If the status is not "active (running)", start the service using the following command:

   sudo systemctl start firewalld

4. List the available services:

   sudo firewall-cmd --get-services

   This will display a list of available services that can be used to create firewall rules.

5. Add a new service to the firewall:

   sudo firewall-cmd --permanent --add-service=<service_name>

   Replace `<service_name>` with the name of the service you want to add. This command adds the service to the permanent rules, so it will persist after a system reboot.

6. Remove a service from the firewall:

   sudo firewall-cmd --permanent --remove-service=<service_name>

   Replace `<service_name>` with the name of the service you want to remove. This command removes the service from the permanent rules, so it will not persist after a system reboot.

7. Reload the firewall configuration:

   sudo firewall-cmd --reload

This command reloads the firewall configuration to apply any changes that have been made to the rules.


8. View the current firewall rules:

   sudo firewall-cmd --list-all

This command displays a list of all of the current firewall rules, including any custom rules that have been added.


That's it! You should now be able to configure firewall rules with Firewalld on RHEL 8.