Vivek Shukla

UFW Cheat Sheet

Check status

sudo ufw status

# or

sudo ufw status verbose

# or

sudo ufw status numbered

Delete value based on number:

sudo ufw delete 5

Allow port

sudo ufw allow 22/tcp

Deny port

sudo ufw deny 80/tcp

Allow from ip address or subnet

sudo ufw allow from 10.22.96.0/20

Allow from ip address to specific port

sudo ufw allow from 10.22.96.0/20 proto tcp to any port 5432

Disable ufw

sudo ufw disable

Block an ip address or subnet

sudo ufw deny from 203.0.113.100

Delete a rule

sudo ufw delete allow from 203.0.113.101

Allow incoming connection to a network interface

sudo ufw allow in on eth0 from 203.0.113.102