How to Disable Firewall on Ubuntu 18.04
3 min read
Ubuntu ships with a firewall configuration tool called UFW (Uncomplicated Firewall). UFW is a user-friendly front-end for managing iptables firewall rules and its main goal is to make managing firewall rules easier or as the name says uncomplicated.
It is highly recommended to keep the firewall enabled. However, in some situations, such as testing you might need to stop or disable the firewall.
In this tutorial, we will show you how to disable the UFW firewall on Ubuntu 18.04 systems.
Make sure you are logged in as a user with sudo privileges.
Checking the Firewall Status
To view the current status of the UFW firewall, use the
ufw status command:
sudo ufw status
UFW firewall is disabled by default. If you have never activated UFW before, the output will look like this:
Otherwise if the firewall is enabled you will see the following message:
Disabling the Firewall
If you are disabling the firewall because you are experiencing connectivity issues or you have troubles configuring your firewall please check our guide about How To Set Up a Firewall with UFW on Ubuntu 18.04.
To disable the UFW firewall on your Ubuntu system, use the
ufw disable command:
sudo ufw disable
The output will look like this:
Firewall stopped and disabled on system startup
The command above will stop and disable the firewall but it will not delete the firewall rules. The next time you enable the firewall the same rules will be loaded.
If you want to disable the firewall and delete all of the firewall rules use the
ufw reset command:
sudo ufw reset
You will be prompted whether you want to continue with the operation:
Resetting all rules to installed defaults. This may disrupt existing ssh connections. Proceed with operation (y|n)?
Backing up 'user.rules' to '/etc/ufw/user.rules.20190122_115214' Backing up 'before.rules' to '/etc/ufw/before.rules.20190122_115214' Backing up 'after.rules' to '/etc/ufw/after.rules.20190122_115214' Backing up 'user6.rules' to '/etc/ufw/user6.rules.20190122_115214' Backing up 'before6.rules' to '/etc/ufw/before6.rules.20190122_115214' Backing up 'after6.rules' to '/etc/ufw/after6.rules.20190122_115214'
Resetting UFW firewall is helpful when you want to revert all of your changes and start fresh.
Enabling the Firewall
Before enabling the firewall, make sure that the SSH port is open for connection.
To enable the firewall run:
sudo ufw enable
When asked type
y to continue with the operation:
Command may disrupt existing ssh connections. Proceed with operation (y|n)?
Firewall is active and enabled on system startup
In this tutorial, you have learned how to stop and permanently disable the firewall on a Ubuntu 18.04 machine.
Most of the UFW commands are intuitive and easy to remember. For example,
ufw status shows the status of the firewall and
ufw disable disables the firewall.