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 a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.