Firewalls play a crucial role in improving the security of computer networks and preventing unauthorized access. In Linux, a tool named Uncomplicated Firewall (UFW) is used to manage these rules efficiently. This tool also has a graphical frontend, which is known as Graphical Uncomplicated Firewall (GUFW). In this guide, we’ll explain how to install and use GUFW on Ubuntu.
Note: while the instructions below are shown for Ubuntu, it will work for most Linux distributions too.
Install GUFW on Ubuntu via Terminal
GUFW can be easily installed on Ubuntu using the apt package manager. Before proceeding with GUFW installation, make sure the Universe Repository is enabled on your system because GUFW is available in this repository:
sudo add-apt-repository universe

Now that the Universe Repository is added, update the package repository:
sudo apt update
Once your system is updated, run the command below to install GUFW on your Ubuntu machine:
sudo apt install gufw -y

Install GUFW on Ubuntu via Software Center
GUFW can also be installed from the Ubuntu Software center. First, open Ubuntu Software Center, type GUFW in the search bar, and select the application to be installed:

Click on the Install button to begin the GUFW installation process:

It will be installed on your system in just a few minutes.
Note: If you are not using Ubuntu, you will be able to find GUFW in your distro’s package manager.
Enable or Disable GUFW on Ubuntu
After successful installation of GUFW, you can access it on your system by executing the following command:
sudo gufw
Alternatively, you can access it through your menu. Navigate to the system menu, search for GUFW, and select the Firewall Configuration application to open it:

The GUFW home screen displays various details, such as the profile, status, and information about incoming and outgoing traffic rules. The status switch shows whether the firewall is running or not.
To enable or disable GUFW, you can toggle the status switch on or off:

Edit GUFW Profiles
GUFW comes with different preconfigured firewall settings. You can click the dropdown next to the profile to view the preconfigured profiles. These profiles represent different levels of security, and based on the selected profile, the firewall applies corresponding rules to manage network traffic:

There are three preconfigured profiles, whose details are listed below:
1. Public Profile
Public profile in GUFW is designed for untrusted networks like public Wi-Fi. It blocks all incoming connections to reduce the attack surface and allows outgoing connections, so you can still browse the internet and access external services. Using the public profile on a public network helps protect your system from unauthorized access or threats.
2. Office Profile
It allows outgoing connections and can be configured to restrict incoming connections based on your organization’s needs. It’s suitable for use in a corporate or office environment.
3. Home Profile
The Home profile allows all outgoing connections and permits certain incoming connections for trusted services like SSH or web access. It’s suitable for use on a home network where devices are generally trusted.
Apart from preconfigured profiles, we can also create custom profiles and delete any unnecessary profiles.
To edit a profile, go to the Edit tab and select Preferences:

To add a new profile, click on the + icon at the bottom of the Firewall Preferences window:

By default, the new profile will be named Profile1, Profile2, etc. Double-click on it to rename it:

To delete a profile, select the profile to be removed and click the – button:

Now, click the close button to exit the Firewall preference and proceed with other rules.
Understanding GUFW Rules
GUFW lets you create custom rules for each of its profiles. These rules help manage how data flows in and out of your computer network. To set up the right rules, it’s important to understand your network setup and the level of security you need. Moreover, keeping your firewall rules up to date and regularly reviewing and adjusting them helps you better control network traffic and block any unwanted access.
GUFW offers several types of rules you can apply to manage network connections:
- Allow: It allows all data through a specific port without any restrictions.
- Deny: Blocks all incoming data through the selected port.
- Reject: It is similar to “Deny”, but it also sends a message back to the sender to let them know the connection was refused.
- Limit: Blocks access if someone tries to connect too many times in a short period (for example, more than six attempts within 30 seconds). It reduces the chances of potential attacks like brute force.
Add GUFW Rules
To add a GUFW rule, first you need to select the profile for which you want to add the rule, then click the plus + button:

A new window opens where you can add firewall rules. This window is divided into three tabs: Preconfigured, Simple, and Advanced.
- Preconfigured is the easiest option. It lets you quickly allow or block common services like HTTP or SSH with just a few clicks.
- Simple is also beginner-friendly but gives you more control, such as choosing specific ports and setting rule direction.
- Advanced is for users who need detailed control. It allows you to create rules based on IP addresses, subnets, protocols, and network interfaces:

Select the policy, direction, category, subcategory, and application as needed, then click the Add button to apply the rule.
Edit GUFW Rules
GUFW lets you edit an existing rule. To do that, select the rule to be edited and click on the gear icon:

Now, on the pop-up window, you can update the firewall rule and click Apply to save the changes:

This is how you can set up and use a Graphical Uncomplicated firewall on Ubuntu. It’s always a good practice to keep the firewall enabled and configure the right rules using GUFW. It helps you protect your system from unauthorized access while allowing safe connections. For more security, you can install antivirus software to protect your system from potential threats and malware.