Configure UFW on Ubuntu

Installation of UFW:

UFW is already installed on Ubuntu 18.04. You can verify it from here

$ which ufw

Enable/Disable/Reload UFW:

Enable UFW:

$ ufw enable

Disable UFW

$ ufw disable

Reload UFW:

$ ufw reload

If you don’t receive output, you need to install UFW. Please refer the following commands. $ sudo apt-get install ufw

Allow/Deny port:

Allow port:

$ sudo ufw allow 80/tcp

Change the port which you want to open.

Deny port:

$ sudo ufw deny 80

Change the port which you want to deny

Check Status of UFW:

$ sudo ufw status

Removing rules:

First, check the status of UFW using numbered.

$ sudo ufw status numbered

This command will show the rules with numbers

Now remove the rule using the following command(Replace the 1 with the rule number which you want to remove)

$ sudo ufw delete 1