UFW Firewall - An Easy To Use Linux Firewall


Table of Contents

UFW stands for Uncomplicated Firewall is a firewall to secure Linux desktops from harmful incoming and outgoing connections. UFW is the easiest firewall in Linux, it has a graphical user interface GUFW with all the features of setting up rules. In this tutorial, we will install UFW & GUFW in our Ubuntu/Linux Mint/Debian operating system.

What Is a Firewall?

When you google what is a firewall, you get a Wikipedia page that tells about the firewall. According to Wikipedia firewall is –

In computing, a firewall is a

  • network security system that controls the incoming and outgoing network traffic based on an applied rule set.
  • establishes a barrier between a trusted, secure internal network and another network (e.g., the Internet) that is assumed not to be secure and trusted.
  • exist both as software to run on general-purpose hardware and as a hardware appliance.

Many hardware-based firewalls also offer other functionality to the internal network they protect, such as acting as a DHCP server for that network.

linux free firewall gufw install

Firewall simply acts as a protection between a computer and network.

Why To Install Firewall?

Computers are connected and they share data and some personal information with servers. The same way servers are connected with computers and they do share data depending on the request from the client computer. But among those millions of connections, there are dangerous connections too that steal private data from servers or desktops.

So to recognize and prevent such harmful and dangerous connections we use a firewall. We can configure rules manually about the connections or there are also default set up rules in the firewall that stop certain connections to interact with the system through the network.

How To Install UFW (Uncomplicated Firewall) In Linux?

In Ubuntu UFW is by default installed but if you doubt then you can check it by the following command –

$ sudo dpkg --get-selections | grep ufw
is ufw firewall installed in linux

Is the firewall installed? If not, you can install it from terminal.

$ sudo apt-get install ufw

Once you have installed UFW you can configure this firewall from the terminal. But UFW is known for its simplicity and ease of use. So we will use the graphical user interface GUFW instead of the terminal. Yeah!

So open up software manager and search for ‘GUFW’ and install it –

install gufw firewall from software center in linux

Here you have installed a graphical user interface and just open it up system settings, start menu, or dash.

I am using Ubuntu so I’ll start the firewall from the dash.

start gufw firewall from dash or start menu in linux

Here we have a nice, easy-to-use firewall interface that everyone can understand. The interface has the following easy options – Profile – Profile menu has some inbuilt profiles for Home (set by default), Office, and Public. Incoming and Outgoing connections for each profile –

ufw graphical user interface application in linux firewall
ufw graphical user interface application in linux firewall

Status – If you need to turn off the firewall, in gufw you only click this button and to turn back on clicking the button again.

gufw firewall connections configuration settings

Connection settings – GUFW allows to change default profile Incoming and Outgoing connections settings.

Now move down the side of the application. Here we have some very simple firewall customization tools.

Listening Report – Under the listening report, we have the list of services, and applications using incoming or outgoing connections. Each service and application behaving differently and have their own set of rules and rules can be customized also.

ufw linux firewall listening report
ufw linux firewall listening report

Add a Firewall Rule – Select any service or application and click the ‘plus’ sign and it will open the window that is on left. The window has three tabs ‘Preconfigured’, ‘Simple’, and ‘Advanced’.

gufw add firewall rule preconfigured

Preconfigured – Here you have preconfigured settings for applications.

gufw add rule simple

Simple – Here you can select specify some very simple rules, like rule name, Policy, Direction, Protocol, and Port.

gufw add rule firewall advanced

Advanced – In addition to some simple settings in the advanced tab you can set some other rule settings. For example, Inserts, Interface, you can also set whether you want to make log, log all, or do not log. The advanced tab has one more option to set up a range of IP address for a selected application.

gufw created rule

After you have set up rules click Add. Rules added! You can see your added rules under Rules.

You can edit the rules and delete the rules.  To edit any rule select it and click the setting icon below the list.

To delete any rule select rule and click ‘minus’.


gufw firewall connection log

In the last of the application, you have log. Under log, there are all activities of the applications or services status of incoming and outgoing connections. The log helps in identifying any suspicious activity of any applications.

A firewall is one of the best security tools. Hackers find an open port and attack through. Firewall restricts any of such malicious connections. UFW is the easiest one there are many others that protect the system Iptables and Shorewall are a very good example.