UFW Cheatsheet

UFW Cheatsheet

UFW cheatsheet

Installation

sudo apt install ufw

GUI version

sudo apt install gufw

Enable firewall

sudo ufw enable

Check rules & status

sudo ufw status
sudo ufw status verbose

Allow applications

sudo ufw allow ssh            # Allow SSH port 22

sudo ufw allow http           # Allow web server port 80
sudo ufw allow https          # Allow web server port 443

sudo ufw allow 4444           # Allow port 4444
sudo ufw allow 4444/tcp       # Allow port 4444 TCP only
sudo ufw allow 4444/udp       # Allow port 4444 UDP only

sudo ufw allow 1714:1764/udp  # Allow Port From 1714 to 1764 UDP
sudo ufw allow 1714:1764/udp  # Allow Port From 1714 to 1764 TCP

Note: Refer to /etc/services for all services
Note: Port range doesn’t supprot both TCP and UDP at once.

Remove allowed applications

sudo ufw delete allow ssh     # Remove Allow SSH Entry

Note: After removing an entry firewall will use default rules for that port,default rule is deny incoming.

Reload firewall

sudo ufw reload

Other Resources


Original:  Updated: