How to Configure a Firewall in Ubuntu Linux using UFW step by step

A firewall It is one of the most important programs on our computer, it could be said that it is essential if it is used to surf the web, since it is designed to block unauthorized access, while allowing authorization to several servers. But if you are not yet familiar with them, we recommend that you investigate what they are, what they are for and how Firewalls work.

This is used to prevent internet users from accessing private networks connected to the Internet. All the information and messages that enter and leave through a server go through a firewall, which examines each message and blocks those that do not comply with the specified security rules. You can even create inbound and outbound rules in the Firewall

Although Linux is one of the most secure operating systems, this does not mean that it is not vulnerable to malware. Although most Ubuntu users do not use firewalls, we recommend installing it, since it never hurts to have a little more security on our computer.

For this we are going to install the UFW firewall, which is super easy to configure and is already on the Linux UFW command line. It is available to all Ubuntu users.

Steps to install Firewall

firewall icon with green background

Installing it is very simple, it has only 2 steps. There are two ways to do it, through the software itself and through commands, unlike Windows when disabling the Firewall. The next steps are through the software directly.

Step 1

In order to install the software, it can be done by opening the Ubuntu software center, and in the search engine type “GUFW” and press “Intro”.

Step 2

The application will appear and you will see a button that says “Install”, click it. Then it will ask for your user password to be able to perform the installation.

Optional step

Some people think that it is faster to install it by commands, if that is the case here we leave you the command: sudo apt install gufw –y

Steps to configure

illustration of firewall configuration for pc

The setup, as well as the installation, is very easy and fast and it is only two steps. We will explain it in a simple way so that it is less tedious.

Step 1

Since UFW is installed, it is time to enable the firewall. To do this, open the application which can be found in the applications menu.

Step 2

After having the application open, we can see that it is deactivated. To activate it, go to the available options and you will see that there is one called “Status” and has a button with “ON” and “OFF”.

After activating it, you will be able to activate any of the three pre-established security profiles. Let’s see what those three profiles are.

Preset security profiles


This is the preset profile that activates UFW at the time of pressing “ON”. This profile has standard security rules and allows users to have more freedom when opening ports.


This is the most preset profile strict available for the UFW firewall system. It has quite strict filtering characteristics. This profile is perfect for laptop users who tend to connect to public or high-traffic networks.


The safety profile Office for UFW It is quite similar to “Home”, it has standard security and is good for setting special rules in your workplace.

Allow or deny traffic

Another of the UFW settings is allowing or denying traffic access through the firewall. Below we will briefly explain how you can configure it.

Step 1

View the option “Rules”, then click it. Press the “+” option located at the bottom left of the application window.

Step 2

Now click on the tab “Preconfigure” and look for the option “Politic” and if you want to allow or deny access press “Allow” or “Deny”.

Step 3

You will be able to see the option “Direction”, press the option. Then set it to either “IN”, “OUT” or “BOTH”, depending on your needs and preferences.

Step 4

Finally go to option “App”, a menu list will pop up to allow a particular application to be configured with the firewall. Select the “Add” option to add a new rule to the UFW Firewall, that’s it. The most important thing is the security of your files and data, that is why we recommend that you always have a firewall installed. Something interesting is that you can allow or block a program in the Firewall.

How useful did you find this content?

Click on a star to rate!

Average score 0 / 5. Counting of votes: 0

So far, no votes. Be the first to rate this content.

I'm sorry this content was not useful for you!

Let me improve this content!

Tell me, how can I improve this content?

Deja un comentario