›INDEX
Last Updated:

UFW firewalls

Installation

sudo apt install ufw

Check UFW status

sudo ufw status verbose

Note: UFW has to be executed pre-fixed by sudo or if switching to root use su - since ufw command isn't available by default to any of the users.

Useage

By default, UFW will block all of the incoming connections and allow all outbound connections. Defaults can be changed using the following command:

sudo ufw default <policy> <chain>

List apps

sudo ufw app list

For more info on a particular app: sudo ufw app info 'Nginx Full'

Allow connections

To allow connections using the apps:

sudo ufw allow ssh

To allow connections using the port and the protocol:

sudo ufw allow 4422/tcp

Allow for port ranges:

sudo ufw allow 7100:7200/udp

Allow specific IP addresses (optionally to a specific port) :

sudo ufw allow from 64.43.12.41
sudo ufw allow from 64.43.12.41 to any port 22

Allow subnets:

sudo ufw allow from 192.168.1.0/24 to any port 3306

Enable and Disable UFW

sudo ufw enable
sudo ufw disable

Deny connections

sudo ufw deny from 23.24.25.0/24
sudo ufw deny from 23.24.25.0/24 to any port 443

Delete UFW rules

To see the rules that have been enabled:

sudo ufw status numbered

Delete based on number or on port:

sudo ufw delete 3
sudo ufw delete allow 8069

Enjoy the notes on this website? Consider supporting me in this adventure in you preferred way: Support me.