How To Disable and Stop Firewall on Linux(CentOS/Ubuntu)

This post will guide you how to disable Firewall on your CentOS 7 or CentOS 8 or Ubuntu Linux system. How do I Stop Firewalld or UFW service on your CentOS or Ubuntu Linux from the command line.

Disable and Stop Firewall on Linux1

What is Firewalld


firewalld provides a dynamically managed firewall with support for network/firewall zones to define the trust level of network connections or interfaces. It has support for IPv4, IPv6 firewall settings and for ethernet bridges and has a separation of runtime and permanent configuration options. It also supports an interface for services or applications to add firewall rules directly.

What is UFW


UFW is used by Ubuntu and Debian Linux system for managing a netfilter firewall. This program is for managing a Linux firewall and aims to provide an easy to use interface for the user.

Checking Firewall Status


If you need to check the current status of the firewalld service or checking if a frewalld service is running or not in your CentOS or RHEL system, and you can use the following command:

$ sudo firewall-cmd --state

Or

$ systemctl status firewalld

outputs:

[devops@mydevops ~]$ sudo firewall-cmd --state
running
[devops@mydevops ~]$ systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-10-08 02:53:52 EDT; 6h ago
Docs: man:firewalld(1)
Main PID: 846 (firewalld)
Tasks: 2 (limit: 8297)
Memory: 31.0M
CGroup: /system.slice/firewalld.service
└─846 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid

Oct 08 02:53:50 mydevops.com systemd[1]: Starting firewalld - dynamic firewall daemon...
Oct 08 02:53:52 mydevops.com systemd[1]: Started firewalld - dynamic firewall daemon.

If you want to check if a UFW firewall is running or not on your Ubuntu or Debian based system, and you can use the following command:

$ sudo ufw status

Outputs:

devops@devops:~$ sudo ufw status
Status: active

Stopping Firewall


If you want to stop the firewalld service temporarily on your CentOS or RHEL Linux system, you can type the following command:

$ sudo systemctl stop firewalld

It is only valid for the current runtime session.

For Ubuntu or Debian Linux:

$ sudo ufw disable

Outputs:

devops@devops:~$ sudo ufw disable
Firewall stopped and disabled on system startup

Disabling Firewall


If you want to disable the firewalld service or UFW in CentOS or Ubuntu system at boot time, you can use the following command:

$ sudo systemctl disable firewalld

or

$ sudo ufw disable

Outputs:

[devops@mydevops ~]$ sudo systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[devops@mydevops ~]$

devops@devops:~$ sudo ufw disable
Firewall stopped and disabled on system startup

Enabling Firewall


if you want to enable the Firewall service or UFw based firewall on your CentOS or Ubuntu Linux system, and you can type the following command at the shell prompt:

$ sudo systemctl enable firewalld

or

$ sudo ufw enable

Outputs:

[devops@mydevops ~]$ sudo systemctl enable firewalld
Created symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service → /usr/lib/systemd/system/firewalld.service.
Created symlink /etc/systemd/system/multi-user.target.wants/firewalld.service → /usr/lib/systemd/system/firewalld.service.


devops@devops:~$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

Conclusion


You should know that how to stop and disable the firewalld service or UFW based firewall in your CentOS or RHEL or Ubuntu Linux system.

You might also like:

Sidebar



back to top