Ubuntu Firewall Cheat Sheet

Protocol: tcp udp

Enable Firewall

sudo ufw enable

Disable Firewall

sudo ufw disable

View Firewall Status

# Simplesudo ufw status# Verbosesudo ufw status verbose

Firewall Rules

# Display Firewall Rule Numberssudo ufw status numbered# Delete Firewall Rule by Numbersudo ufw delete [Number]

View Firewall Default Policy

ufw status verbose | grep -i default

Change Firewall Default Policy

ufw default allow|deny|reject [incoming|outgoing|routed]

Allow IP Address/Range

ufw allow from [Remote IP] to [Local IP] proto [Protocol] port [Incoming Port]

Deny IP Address/Range

ufw deny from [Remote IP] to [Local IP] proto [Protocol] port [Incoming Port]

Allow port

ufw allow [Incoming Port]/[Protocol]

Deny port

ufw deny [Incoming Port]/[Protocol]

Delete Firewall Rule

ufw delete allow ...ufw delete deny ...

Remove all Firewall Rules

ufw reset