In this tutorial, we will explain How to install Firewalld on CentOS.

firewalld is a firewall management tool for Linux operating systems. It provides firewall features by acting as a front-end for the Linux kernel’s Netfilter framework via the iptables command, acting as an alternative to the iptables service. The name firewalld adheres to the Unix convention of naming system daemons by appending the letter ā€œdā€.

Prerequisites

  • VPS running CentOS

Step 1 – Install Firewalld

Firewall is needed for most software. To install it run the following command:

yum install firewalld

To start it run this command:

systemctl start firewalld

To enable it, run:

systemctl enable firewalld

To check the status of firewalld service:

systemctl status firewalld

Step 2 – Add service

You need to add services to firewalld if you want to access any service.

firewall-cmd --add-service=http --permanent

In that command, you need to put the service name that you want to add, for example, http.

To remove any service use this command:

firewall-cmd --remove-service=http --permanent

To check all service in your server run this command:

ls /usr/lib/firewalld/services

Step 3 – Add Ports

By using this command you can open any port in firewalld:

firewall-cmd --add-port=8080/tcp --permanent

To remove any port, use this command:

firewall-cmd --remove-port=8080/tcp --permanent

You can change /tcp with /udp based on your needs.

Step 4 – Use Firewall

To configure Firewalld, you need to use this command:

firewall-cmd

Using this command you can see all ports, services, sources, interfaces, etc.

firewall-cmd --list-all

Conclusion

You have successfully installed firewalld on CentOS.

Enjoy.