How to configure a firewall in Ubuntu Linux using UFW step by step

Who I am
Shane Conder
@shaneconder
Author and references

Un firewall is one of the most important programs on our computer, it could be said that it is essential if it is used to browse the web, as it is designed to block unauthorized access, while still allowing authorization to multiple servers. But if you don't know them yet, we recommend that you investigate what they are, what they are for, and how firewalls work.

It is used to prevent Internet users from accessing private networks connected to the Internet. All information and messages entering and leaving 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



While Linux is one of the safest operating systems, that doesn't mean it's not vulnerable to malware. Although most Ubuntu users don't use firewalls, we recommend installing it, as it never hurts to have a little more security on our computer.

For this we will install the firewall UFW, which is super easy to set up and is already on the Linux UFW command line. It is available for all Ubuntu users.

Steps to install the firewall

 

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

Step 1

To install the software, you can open the Ubuntu software center and in the search engine type "GUFW" and press "Enter".

Step 2

The application will appear and you will see a button that says “Install”, click on it. It will then ask for your user password to install.



Optional step

Some people think it is faster to install it via commands, in that case here is the command: sudo apt install gufw –y

Steps to configure

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

Step 1

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

Step 2

After opening the application, we can see that it is disabled. To activate it, go to the available options and you will see that there is one called "State" and has a button with "ON" and “OFF”.

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

Preset security profiles

casa

This is the preset profile it activates UFW when you press “ON”. This profile has standard security rules and allows users to have more freedom when opening doors.

Public

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

Office

The safety profile of Office per UFW it is quite similar to "Home", has standard security and is useful for setting special rules in the workplace.


Allow or deny traffic

Another of the UFW settings is to allow or deny access to traffic through the firewall. Below we will briefly explain how this can be configured.


Step 1

See the option "Rules", then click it. Press the "+" option located at the bottom left of the application window.

Step 2

Now click on the "Preconfigure" tab and look for the "Policy" option and if you want to allow or deny access click “Consent” o “Care”.


3 pass

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

4 pass

Finally go to the option "Application", a list of menus will appear to allow you to configure a particular application with the firewall. Select the “Add” option to add a new rule to UFW Firewall, that's it. The most important thing is the security of your files and data, so we recommend that you always have a firewall installed. Something cool is that you can allow or block a program in the firewall.


add a comment of How to configure a firewall in Ubuntu Linux using UFW step by step
Comment sent successfully! We will review it in the next few hours.