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

    

shell   sudo ufw default deny incoming
sudo uwf default allow outgoing

Allow HTTP (80)

    

shell   sudo ufw allow http

or

shell   sudo ufw allow 80

Allow HTTPS (443)

    

shell   sudo ufw allow https

or

 
shell   sudo ufw allow 443

Allow a Port Range

    

shell   sudo ufw allow 8000:8100/tcp

Allow entire subnet to all ports

    

shell   sudo ufw allow from 192.168.1.0/24

Allow a specific IP

    

shell   sudo ufw allow from 192.168.1.50

Allow IP to a specific port

    

shell   sudo ufw allow from 192.168.1.50 to any port 22

Allow subnet to specific port with specific protocol with comment

    

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