Linux disable firewall command

I am a new Linux system administrator. I have a hardware-based firewall, so I don’t need a firewall on each server. How do I disable the firewall on Linux?

You can easily disable the Firewall for Linux. Most modern Linux distrubtion use the following tools:


  1. ufw – Used by Ubuntu and Debian based system to manage the firewall.
  2. firewalld – Used by RHEL, CentOS and clones. It is a dynamic solution to manage the firewall.

The author of the tutorial recommends that you run the software firewall even if you have a hardware-based firewall. Do not disable firewalld/ufw as it protects the individual server/VM.

Linux disable firewall command

Let us see how to stop and disable Firewalld on a CentOS or RHEL 7.x based system.

Is firewalld running on my system?

sudo firewall-cmd --state

Stop the the firewalld

Again, type:
sudo systemctl stop firewalld

Disable the FirewallD service at boot time

sudo systemctl disable firewalld
sudo systemctl mask --now firewalld

Linux disable firewall command using firewalld

Verify that the FirewallD is gone

Simply type:
sudo systemctl status firewalld
Sample outputs:

* firewalld.service
   Loaded: masked (Reason: Unit firewalld.service is masked.)
   Active: inactive (dead)
Apr 09 13:54:23 nixcraft-nuc systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 09 13:54:24 nixcraft-nuc systemd[1]: Started firewalld - dynamic firewall daemon.
Apr 16 23:34:29 nixcraft-nuc systemd[1]: Stopping firewalld - dynamic firewall daemon...
Apr 16 23:34:29 nixcraft-nuc systemd[1]: Stopped firewalld - dynamic firewall daemon.

For more info see:

How do enable the firewalld again?

Simply run the following commands:
sudo systemctl unmask --now firewalld
sudo systemctl enable firewalld
sudo systemctl start firewalld
## verify that the firewalld started ##
sudo firewall-cmd --state

Linux disable ufw based firewall

ufw is easy to use app for managing a Linux firewall and aims to provide an easy to use interface for the user. It is the default on Ubuntu and can be installed on Debian, CentOS, and other Linux distros.

Is the ufw running?

The syntax is:
sudo ufw status

Stop the ufw on Linux

sudo ufw disable

Disable the ufw on Linux at boot time

sudo systemctl disable ufw

Verify that the ufw is gone

sudo ufw status
sudo systemctl status ufw

Linux disable ufw firewall command
For more info see:

How do enable the ufw again?

Just issue the following two commands to enable the firewall and protect your box again:
sudo systemctl enable ufw
sudo ufw enable
## verify that ufw started ##
sudo ufw status

A note about older Linux distro

You need to use the service command and you must be a root user to run the following commands:

Stop the iptables service on Linux

service iptables stop

Disable the iptables service at boot time on Linux

# chkconfig iptables off
See “How To: Disable Firewall on RHEL / CentOS / RedHat Linux” for more info.


In this page, you learned how to stop and permanently disable the firewall on a Linux based operating system using various command line options.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04


Comments on this entry are closed.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.