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

Output
Available applications:
  OpenSSH

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

Output
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 skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting danya.dk