How to Start / Stop or Enable / Disable Firewall Service on Red Hat / CentOS and Debian / Ubuntu Linux

Why should you disable firewall service in Linux? Normally in production environment hardware-based firewall should be placed to protect outside access or to filter packets to and fro into the servers. In this case, you might not required to enable firewall service on each server. Still you want to start/stop and enable/disable firewall service in .RPM Based (CentOS, RHEL etc.) or .DEB based (Debian & Ubuntu etc.) Linux. Firewalld is the daemon which is installed by default in CentOS/RHEL 8 Linux. On Red Hat Linux 8 nftables is the default network packet filtering which has replaced earlier iptables framework. FirewallD is a dynamic daemon to manage firewall with support for networks zones. FirewallD package is installed by default in RHEL/CentOS Linux 7 onward. UFW or Uncomplicated Firewall is installed on Debian or Ubuntu Linux by default. In this article, we will explain how to start/stop and enable/disable firewall service in CentOS/RHEL and Debian/Ubuntu Linux.  

Followings are the steps to start/stop, enable/disable and check the status of Firewall Service on CentOS/RHEL and Debian/Ubuntu Linux.
Note: We recommend you to enable software-based firewall even if you have a hardware-based firewall is installed in your environment. This would provide the second layer of security for individual servers. 

On Red Hat / CentOS Linux

1. Check whether Firewall Service is running or not
Following command to check status of firewall service in your system. Currently firewall service is inactive or dead. press q to quit from console. 
# systemctl status firewalld.service
# firewall-cmd –state

2. Start / Stop Firewall Service
If you are using CentOS/RHEL or Fedora Linux, below is the command to start/stop firewall service.

Note: To execute below command, you might required root or sudo access.


# systemctl start firewalld.service


# systemctl stop firewalld.service


3. Check the current states of Firewall Service
Currently firewall service is active or running. press q to quit from console.
# systemctl status firewalld.service
# firewall-cmd –state
4. Enable / Disable Firewall Service
Followings are the command to enable/disable firewall service.

5. Following steps to disable Firewall Service permanently on RHEL/CentOS Linux 

# systemctl stop firewalld.service
# systemctl disable firewalld.service
# systemctl mask –now firewalld.service
Note: Mask the firewall service will prevent firewall to start by other services.

On Debian / Ubuntu Linux

1. Check Status of Firewall Service
Following command to check status of firewall service.
$ sudo ufw status
2. Enable, Disable and Reload UFW Firewall Service
$ sudo ufw disable
$ sudo ufw enable
$ sudo ufw reload
Conclusion: In this tutorial, we have seen simple steps to start/stop and enable/disable Firewall Service in Linux. Big thanks for reading all the way to the end. Please share it with Your Friends & Help Someone… and also Like Our Facebook Page. Let me hear your thoughts in the comments below!

Leave a Comment