What is FirewallD?
FirewallD is a dynamic firewall manager introduced in the CentOS distribution. Its function is to manage network security more effectively and efficiently. Unlike its predecessor, iptables, FirewallD allows users to configure firewall rules without having to stop running services.
How to Set Firewall Using FirewallD on CentOS
Here are the steps on how to set up a firewall using FirewallD on CentOS.
Step 1: FirewallD Installation
Before we get started, make sure that your CentOS is installed. If not, you can install it with the command:
sudo yum install firewalld
Step 2: Starting and Activating FirewalID
Once the installation process is complete, the next step is to start and activate FirewallD. Use the following commands:
sudo systemctl start firewalld
sudo systemctl enable firewalld
Step 3: Defining Security Zones
Security zones in FirewallD is a concept that allows us to group network interfaces according to the desired security level. Choose a zone that suits your server environment, such as 'public', 'private', or 'internal'. Example of using the command:
sudo firewall-cmd --set-default-zone=public
Step 4: Adding Firewall Rules
It is important to specify firewall rules carefully. The command below is an example of adding a rule to open a specific port, for example, SSH port (22):
sudo firewall-cmd --zone=public --add-port=22/tcp --permanent
Don't forget to reload the FirewallD configuration after adding rules:
sudo firewall-cmd --reload
Step 5: Monitoring FirewallD Status
To ensure that the changes you made are working properly, check the status of FirewallD:
sudo firewall-cmd --state
Conclusion
By following the steps above, you have successfully set up a firewall using FirewallD on CentOS. Your server security is now more secure, and you can manage firewall rules more easily.
Don't forget to always update and customize firewall rules according to the specific needs of your server. Security is a constant journey, not an end goal.
This is our complete guide on how to set up a firewall using FirewallD on CentOS. Hopefully it will be useful for improving the security of your server.