How to Disable an Ubuntu Firewall

When the firewall gets in your way, you can still be in control

Whether you’re using Ubuntu Linux as a desktop or server, you should be taking advantage of a firewall. Why? Because the firewall protects your machine from being hacked. It’s not a 100 percent solution, but it certainly makes your machine exponentially more secure.

However, there are times when that firewall gets in the way. Say, for instance, you’re finding your computer isn’t able to reach the network (or other machines cannot reach you). You’ve restarted your modem and, still, your computer cannot reach the internet or be reached via the likes of SSH. What gives? The problem could be the networking subsystem on your computer, or it could be the firewall. Either way, you need to figure out what’s wrong.

That’s just one scenario where it comes in handy to be able to disable the firewall on Ubuntu Linux.

Ubuntu Version

This article uses Ubuntu 18.04 as an example, but the process is the same on any Ubuntu version that is still under support (so 16.04, 16.10, 18.04, and 18.10), as well as any Ubuntu derivative that uses Uncomplicated Firewall.

Why You Don’t Want to Disable the Firewall

For all the reasons you might find to disable your firewall, there’s one reason to keep you from doing so, which is the security of your machine. Once your firewall is down, your machine is open to attack. That doesn’t mean the second you drop the firewall you will be hacked. However, the likelihood that it can happen increases significantly.

To that end, should you find yourself in a situation where you need to disable the firewall on your Ubuntu Linux machine, make sure it is done on a temporary basis only. What does that mean? If you must disable the firewall for a specific reason, make sure to reenable it when you’ve finished the task at hand.

How to Disable the Firewall

ufw status command

The default firewall tool on Ubuntu Linux is Uncomplicated Firewall (UFW).

To find out the current state of your firewall, issue the command:

sudo ufw status

The firewall should be listed as active and also lists out any rules you’ve added.
In order to disable UFW, issue the command:

sudo ufw disable

Issue the command:

sudo ufw status

and the firewall is listed as inactive.

ufw disable command

At this point, run your troubleshooting (or whatever else it is you need to take care of). For example, attempt to Secure Shell into the machine with the now-disabled firewall. If you can get in (but couldn’t previously), the issue might well be that you haven’t allowed SSH connections in. To remedy that, issue the command:

sudo ufw allow ssh

Once you’ve taken care of that, reenable UFW with the command:

sudo ufw enable

Hopefully, that solves your problems.

Verbose Status

ufw status verbose command

If you need more information about the status of UFW, you can always run the status command with the verbose switch. This command is:

sudo ufw status verbose

The verbose output includes logging level, default policies, and any rules you’ve added.

Resetting the Rules

Resetting ufw

If you feel you need to completely start over with UFW and you don’t want to go through the process of deleting all of your rules, you can always run a reset. To do this, issue the command:

sudo ufw reset

You are prompted to OK the operation before it goes on with the deletion of your rules. This also has the added effect of disabling UFW. Because of this, you’ll want to reenable UFW after running the reset. The end result of the reset is a clean slate with which to start.

Was this page helpful?