How to Enable/Disable Firewall on Ubuntu 20.04 LTS

When it comes to firewall protection for your system, the default Ubuntu UFW program is a great option. It is short for “uncomplicated firewall.” It allows users with little knowledge on how Linux IPTABLES so you can secure your home network or server without the need to learn complicated long-tail commands that is more for the sysadmin side of things.

The tutorial is aimed more at new Ubuntu desktop users, but servers can also use the same commands. You will learn how to check, enable and disable the UFW firewall and, for desktop users, install the firewall GUI to better control UFW for users that do not want to use the terminal in the future.

Check UFW Firewall Status

For users new to Ubuntu, you can open the command terminal, which you can open following the top right-hand corner Activities > Show Applications > Terminal.

Example:

Enable/Disable Firewall on Ubuntu 20.04 LTS

Next, find out the status of your UFW firewall using the command.

sudo ufw status

Example output:

Enable/Disable Firewall on Ubuntu 20.04 LTS

As above, the firewall is currently inactive as Ubuntu does not enable this by default for new installations.

Enable UFW Firewall

The next step is to enable the firewall, which by default will block all incoming connections and allow all outgoing connections. This will immediately help secure your system.

For server users or any other user that is using an SSH remote connection session, you may lock yourself out. Luckily, you can add UFW rules while the service is not active, so allow the SSH service as follows.

sudo ufw allow ssh

Desktop users that do not use or know what SSH is, skip the command above.

Example output:

Enable/Disable Firewall on Ubuntu 20.04 LTS

Using the following command, enable the firewall.

sudo ufw enable

Example output:

Enable/Disable Firewall on Ubuntu 20.04 LTS

Next, recheck your Ubuntu firewall re-using the ufw status command.

sudo ufw status

Example output:

Enable/Disable Firewall on Ubuntu 20.04 LTS

As above, the firewall is enabled, and for users that had to allow SSH, you can see this is now in the allowed action.

Additionally, you can run the ufw status command with verbose attached for an even more detailed view.

sudo ufw status verbose

Example output:

Enable/Disable Firewall on Ubuntu 20.04 LTS

Besides the allow, deny actions (rules), you can see the default firewall settings as explained earlier, which are to deny all incoming and allow all outgoing.

Disable UFW Firewall

Next, you can use the following command for users wishing to disable their firewall.

sudo ufw disable

Example output:

Enable/Disable Firewall on Ubuntu 20.04 LTS

Install UFW Firewall GUI

For users new to Linux, while in the terminal, if you do not fancy using the terminal you can install a software package that will control UFW with a graphical interface with the following command.

sudo apt install gufw -y

Next, go to the top left-hand corner and follow Activities > Show Applications > Firewall to bring up the GUI.

Example:

Enable/Disable Firewall on Ubuntu 20.04 LTS

Next, you can enable or disable the UFW firewall and other much more manageable settings.

Example GUI:

Enable/Disable Firewall on Ubuntu 20.04 LTS

As above, you can now adjust connections of default incoming and outgoing connections, check status, create rules, see logs and reports, and more, making using a firewall a much more enjoyable task for non-terminal users.

Comments and Conclusion

In the tutorial, you have learned how to enable/disable a firewall on Ubuntu 20.04 LTS and install the GUI for better protection.

Overall, the GUI is the preferred option for desktop users as even people that use the command terminal may not always want to execute commands to toggle protections on and off all the time, but do make sure you secure your system as even though Linux is safer than Windows it is still prone to be hacked.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!