Tutorial To Setup A Firewall On Ubuntu 20.04 With UFW
This article describes how to monitor and filter incoming and outgoing network traffic with firewalls in Ubuntu 20.04 LTS.
Uncomplicated Firewall or UFW is a front-end for managing iptables firewall rules in Ubuntu 20.04 LTS.
Run the following command to install UFW in Ubuntu 20.04 LTS.
sudo apt update
sudo apt install ufw
Note: UFW is part of the standard Ubuntu 20.04 installation.
You can check the status of the UFW as it is disabled by default.
sudo ufw status verbose
To enable UFW:
sudo ufw enable
To reset UFW:
Run the following command to reset the UFW:
sudo ufw reset
The default polices of UFW firewall are defined in the
To set the defaults used by UFW, run the following commands:
sudo ufw default deny incoming sudo ufw default allow outgoing
Run the following command to list out the application profile.
sudo ufw app list
Allow SSH connection:
sudo ufw allow ssh
Allow Specific IP Addresses
Run the following command to allow specific ip address through the UFW firewall.
sudo ufw allow from 184.108.40.206
Run the following command to allow the subnet of ip addresses.
sudo ufw allow from220.127.116.11/24
Deny Specific IP Address.
Run the following command to deny specific IP Address.
sudo ufw deny from 18.104.22.168