How to Configure a Firewall on Ubuntu 18.04?

0
743
Firewall
Firewall

There is nothing safe from hackers on the Internet, however, we can implement security measures to be more protected against an attack. With this in mind, it is convenient to configure a firewall in our system.

A Firewall is a system that allows protecting a computer or a network of the intrusions that come from the Internet. A firewall behaves as a barrier between the Internet or other public networks and our computer. In the firewall, the incoming and outgoing connections are determined by established rules.

For this reason, it is convenient to take some time to adjust the behavior of the Firewall in the system. Today I will teach you how to configure a firewall in Ubuntu 18.04.

1.-Upgrade the system and verifying the installation

Upgrading the system is always a vital task to perform these types of installations and configurations because doing so provides us with the latest security patches. In short, you’ll have a more secure system. To do this, open a terminal and write:

1.- Upgrading the system
1.- Upgrading the system

As a result of updating the system, you will be able to work with the firewall with the certainty of having more updated and more stable packages.

2. Working with ufw. The firewall on Ubuntu.

By default, Ubuntu has a Firewall installed, but not configured. In other words, it’s almost like not having it. So you have to get to work on it.

First of all, you must enable the service. Without it, the firewall will not run.

2.- Enabling and Starting ufw service
2.- Enabling and Starting ufw service

Now, it’s a good idea to see ufw’s default rules for the system. In this case, run:

3.- Showing the defaults rules for ufw
3.- Showing the defaults rules for ufw

If you plan to use a server, then it’s a good idea to allow connections from ssh.

4.- Allowing ssh connections
4.- Allowing ssh connections

In effect, the above command, tells the Firewall to allow input and output connections to ssh.

In case you want to “open” a port to be used by another application, you must run:

5.- Opening a port with ufw
5.- Opening a port with ufw

Don’t forget to replace 321 with the port you want. If the application uses TCP or UDP, you must change as the case may be.

You can open as many ports as you need. However, these three are basic to working with the computer:

6.- Opening several important ports
6.- Opening several important ports

80/TCP: Used for HTTP
443/TCP: Used for HTTPS
21/TCP: Used for FTP

You can even make a rule to allow or deny connections from any IP address.

With this, you authorize that the applications that come from that IP the firewall will accept them. If the IP address cannot be located, you will see an error like this:

7.- Allowing connections from a single IP
7.- Allowing connections from a single IP

If you are sorry to allow connections to that IP, you can revoke the rule:

Remember to replace “IP” with the corresponding IP address.

However, imagine you’re starting to build a network and you don’t know who to trust, so you can deny connections from all computers.

8.- Denying all incoming connection
8.- Denying all incoming connection

It is also possible to list all the options that the firewall has. Show them with the following command:

8.- Showing the ufw's help
9.- Showing the ufw’s help

As can be seen, manipulating ufw from the terminal is very simple.

3. Using GUFW

As can be seen, manipulating ufw from the terminal is very simple, but if you don’t feel comfortable using CLI, then it is possible to use a GUI for it.

With GUFW, you can configure a firewall on Ubuntu easily. Also, you can apply the same options, but with a convenient graphical management interface. To install it:

10.- Installing gufw
10.- Installing gufw

When you run it, you’ll see a very simple interface like this:

11.- Using GUFW
11.- Using GUFW

If you click on “Rules” and then on the “+” button you can add the rules we have done before per terminal. Remember to first enable the GUFW.

12.- Setting some rules
12.- Setting some rules

You can also check the logs that are generated.

13.- Checking the logs
13.- Checking the logs

As you can be seen, configure a firewall in Ubuntu is simple and provides us with the extra security needed for an operating system. Of course, if we speak at the enterprise level, there are even more customizable and payment solutions to further protect the security of businesses.

Now it’s up to you, tell us about your experience with ufw?

Please share this article on your social networks.

 

Spread the love
  • 4
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here