UFW

UFW (Uncomplicated Firewall)

UFW is an acronym for Uncomplicated Firewall. Although Linux already has other connection control measures, such as iptables, actually controlling the firewall through them is a very complicated task. Canonical therefore decided to create a simple-to-use firewall so that all users can configure iptables using a small number of simple commands.

This firewall is completely free, open source and written in Python. It comes by default in Ubuntu since version 8.04 LTS, and many distros have decided to add it by default because of its usefulness. Also, if it does not come, we can download and install it without problems from their respective repositories.

It is important to note that, although it is the default in many distributions, it is usually disabled. This is done to prevent users from having rule conflicts that can cause hard to identify problems when connecting to the Internet or using certain programs.


Installation and configuration

To install the application we execute the following commands:

sudo apt update
sudo apt install ufw

We can easily check the status of this firewall:

sudo ufw status

To enable or disable the tool:

sudo ufw <enable/disable>

To view the list of applications with rules, run the command as follows:

sudo ufw app list

To see the details of one of the rules, then we will execute the following:

sudo ufw app info app_name

To allow or deny connections on any port of our computer we execute:

sudo ufw <allow/deny> <port>

In addition to enabling a specific port, we can enable a range of ports and even indicate the port protocol as shown below:

sudo ufw allow 50000:53000/tcp

We can also create rules that apply within the LAN so that other PCs on the LAN can connect to our computer. For example:

sudo ufw allow from 192.168.1.100/24 to any port 8080

We can see a complete list with all the rules and instructions we have created in our firewall using this command:

sudo ufw status numbered

Taking into account the numbers shown in the previous command, if we want to delete any rule, we execute the following instruction:

sudo ufw delete <num>

And finally, if we want to reset the firewall completely, we can do it in a simple way by stopping it as we have seen before and executing:

sudo ufw reset

All rules will be deleted and all settings will be reset to factory defaults.