How To Configure Firewall with UFW on Ubuntu 20.04 LTS

UFW (Uncomplicated Firewall) is a firewall management tool for Ubuntu 20.04 LTS. It is a command-line tool that makes it easy to configure and manage iptables, the Linux kernel’s built-in firewall.

Here are the steps to configure the firewall with UFW on Ubuntu 20.04 LTS:

  1. Install UFW by running the following command:
sudo apt install ufw
  1. Enable the firewall by running the following command:
sudo ufw enable
  1. Check the status of the firewall by running the following command:
sudo ufw status
  1. By default, UFW will block all incoming connections and allow all outgoing connections. To allow incoming connections on a specific port, use the following command, replacing “port_number” with the desired port number:
sudo ufw allow port_number
  1. To allow incoming connections on a specific port and protocol, use the following command, replacing “port_number” and “protocol” with the desired values:
sudo ufw allow port_number/protocol
  1. To block incoming connections on a specific port, use the following command, replacing “port_number” with the desired port number:
sudo ufw deny port_number
  1. To block incoming connections on a specific port and protocol, use the following command, replacing “port_number” and “protocol” with the desired values:
sudo ufw deny port_number/protocol
  1. To delete a rule, use the following command, replacing “rule_number” with the number of the rule you want to delete:
sudo ufw delete rule_number
  1. To disable the firewall, use the following command:
sudo ufw disable

You can also configure UFW using ufw app profile, this allow you to configure UFW based on predefined profiles for common services such as apache, ssh, etc.

It’s important to note that changes made to the firewall may disrupt existing connections, so it’s a good idea to test the firewall rules before implementing them in a production environment.

(https://www.manafort.com/)

Leave a Comment