Linux Mint

How to Install and Setup UFW on Linux Mint 21

Uncomplicated Firewall (UFW) is the widely used and easiest command-line tool for handling the network. It is designed specifically for easy firewall configuration through simple commands that run on the terminal. These rules may include the configuration of ports, IPs, and incoming and outgoing connections like allowing and blocking them.

This firewall is not powerful as compared to iptables, but a good start for beginners who are less familiar with firewall concepts. Also, it has a graphical interface to manage firewalls and can be launched using gufw command.

Install and Setup UFW on Linux Mint 21

Here’s a step-by-step guide to show how to set-up UFW on Linux Mint 21 system:

Step 1: Upgrade the system repository to refresh all packages; this would avoid any conflict in the further process:

$ sudo apt update && sudo apt upgrade

Step 2: For firewall configuration, you should have sudo privileges. Confirm with the help of the command if you’re working as the root user:

$ sudo whoami

Step 3: Firewall is pre-installed in all Linux distributions and in case it is deleted or you don’t find it, type the command to install it on your system:

$ sudo apt install ufw

Step 4: Immediately enable the Firewall service using the mentioned command:

$ sudo systemctl enable ufw --now

Step 5: Confirm the UFW status from the following command to check whether it is running successfully on your system:

$ sudo systemctl status ufw

Step 6: In the next move, you must enable the Firewall by yourself through the following command:

$ sudo ufw enable

The above command activates the firewall setting on your Linux Mint system.

Display UFW Applications Profiles

To display all the present applications supported by firewall, type:

$ sudo ufw app list

Let’s apply the rule to any of the above-mentioned applications; like to enable both HTTP and HTTPS server; type the following command:

$ sudo ufw allow ‘Nginx FULL’

The same command applies for other applications as well in case you want to apply rules on these applications.

Set Firewall Policies

The firewall has set the default policies by allowing the outgoing connections and denying the incoming connections for security purpose. In case if you want to set it by yourself, you can change the policies anytime.

For denying the incoming connections, you should apply the following command:

$ sudo ufw default deny incoming

For allowing the outgoing connections, you must use the following command:

$ sudo ufw default allow outgoing

Enable Firewall on SSH Connections

You can also enable firewall on SSH connections to improve the system security and for this, you will require executing the following command:

$ sudo ufw allow ssh

Check UFW Status

You can display the status of all the applied rules on the firewall by executing the following command:

$ sudo ufw status

You can use the verbose flag command given below to display a detailed status update:

$ sudo ufw status verbose

You can also view firewall status updates in a numeric sequence through the following command:

$ sudo ufw status numbered

Setup UFW Firewall Through GUI

The UFW can also be configured using GUI and for this, you will require installing a tool called “gufw” on Linux Mint 21 system from the following command:

$ sudo apt install gufw

After the installation, launch it on the terminal by typing the command “gufw” and this command requires authentication to ensure you’re working as a root user:

Once you enter the correct credentials (password); the firewall screen will open in front of you and you can set the rules according to your choice:

This completes the setup of Firewall on Linux Mint system.

Conclusion

UFW is a popular and easy frontend tool to manage a Netfilter Firewall in a Linux system. Its aim is to make firewall configuration easier for beginners. This guide has mentioned all the necessary details of setting up UFW through different commands and GUI tools. It depends on the user’s choice of which method they want to adopt because both can be used to setup a firewall on Linux Mint system.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.