firewalld is a front-end for the built in netfilter firewall on Linux systems. The main advantage of firewalld over using raw nftables/iptables commands is that it’s easier to use, especially for more complex firewall features like timed rules. In this regard, it’s similar to the uncomplicated firewall (ufw) that comes installed by default on Ubuntu systems.
On CentOS, firewalld is the default firewall interface and should already be installed on your system. In this guide, we’ll take you through the installation of firewalld on CentOS, which includes some basic usage commands so you can get started managing the firewall.
In this tutorial you will learn:
- How to install and update firewalld
- firewalld basic usage commands
Category | Requirements, Conventions or Software Version Used |
---|---|
System | CentOS |
Software | firewalld |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Install and update firewalld
If you’re running a recent version of CentOS like CentOS 8 or CentOS 7, firewalld should already be installed on the system. If it has been removed from the system or you need to update it, use the following command in terminal:
CentOS 8 and newer:
# dnf insall firewalld
CentOS 7 and older:
# yum install firewalld
firewalld basic usage commands
To manage the firewalld service, you can use systemctl commands.
Check the current status of firewalld and see if it’s running:
# systemctl status firewalld
Enable or disable firewalld from starting automatically at system boot:
# systemctl enable firewalld OR # systemctl disable firewalld
Start or stop the firewalld service:
# systemctl start firewalld OR # systemctl stop firewalld
Once you’re ready to start configuring firewalld, we have a guide on the introduction to firewalld and firewall-cmd commands that you should check out.
Conclusion
In this guide, we saw how to install and update firewalld on a CentOS system, as well as how to start, stop, enable, and disable the service. Now that you’ve got it up and running, we recommend checking out our more in depth guide to learn about its configuration.