Linux / Unix

Basic Firewall on Ubuntu Server

UFW can be used to set up firewall on Ubuntu server, that make sure only connections to certain services are allowed.

With UFW we can register different application profiles upon installation. These profile allow UFW to manage these applications by name.

OpenSSH is most commonly used application used to access server shell.

Registered profiles can be listed by running following command.

# ufw app list

Available applications:

In order to access server shell, we need to allow SSH connections. SSH can be allow by running following command.

# ufw allow OpenSSH

Once OpenSSH is allowed, now let’s enable the firewall.

# ufw enable

Type “y” and press ENTER to proceed. You can see that SSH connections are still allowed by typing:

# ufw status

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
At the moment firewall blocks all the connections expect SSH, if you need to install and configure other services; remember to adjust firewall accordingly.

For additional help take a look at "UFW Essentials" well written article by Mitchell Anicas at DigitalOcean community.
Author: Danyal
I'm working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.