Skip to main content

Ufw Cheat Sheet

Ufw

Basic commands

  • sudo ufw status Check status (usually "inactive" by default).
  • sudo ufw status numbered List rules with ID numbers (great for deleting).
  • sudo ufw enable Turn the firewall ON
  • sudo ufw disable Turn the firewall OFF
  • sudo ufw reload ✔Apply changes after editing rules.

Defaults

sudo ufw default deny incoming
sudo uwf default allow outgoing

Allow HTTP (80)

sudo ufw allow http

or

sudo ufw allow 80

Allow HTTPS (443)

sudo ufw allow https

or

sudo ufw allow 443

Allow a Port Range

sudo ufw allow 8000:8100/tcp

Allow entire subnet to all ports

sudo ufw allow from 192.168.1.0/24

Allow a specific IP

sudo ufw allow from 192.168.1.50

Allow IP to a specific port

sudo ufw allow from 192.168.1.50 to any port 22

Allow subnet to specific port with specific protocol with comment

sudo ufw allow from 192.168.10.0/24 to any port 5900 proto tcp comment \
"Allow VNC from .10.0/24 subnet"