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 of how Linux IPTABLES can secure your home network or server without the need to learn complicated long-tail commands that are 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 on Ubuntu 22.04 LTS Jammy Jellyfish. 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.
Table of Contents
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.
Next, find out the status of your UFW firewall using the command.
sudo ufw status
The firewall is inactive as Ubuntu does not enable this by default for new installations.
Enable UFW Firewall
The next step is to enable the firewall, which 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, allowing the SSH service.
sudo ufw allow ssh
Desktop users that do not use or know what SSH is, skip the command above.
Using the following command, enable the firewall.
sudo ufw enable
Next, recheck your Ubuntu firewall by re-using the ufw status command.
sudo ufw status
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
Besides the allow, deny actions (rules), you can see the default firewall settings 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
Install UFW Firewall GUI
For users new to Linux, while in the terminal, you can install a software package that will control UFW with a graphical interface with the following command if you do not fancy using the terminal.
sudo apt install gufw -y
Next, go to the top left-hand corner and follow Activities > Show Applications > Firewall Configuration to bring up the GUI.
Next, you can enable or disable the UFW firewall and other more manageable settings.
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 22.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.