Skip to content

Instantly share code, notes, and snippets.

@mauvehed
Last active January 1, 2025 14:29
Show Gist options
  • Save mauvehed/f57265756478f1b3d53b48b807fb2b47 to your computer and use it in GitHub Desktop.
Save mauvehed/f57265756478f1b3d53b48b807fb2b47 to your computer and use it in GitHub Desktop.
UFW Quick Start

Quck Start

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu

Should be yes:

grep IPV6 /etc/default/ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw show added
sudo ufw enable

Examples

sudo ufw allow OpenSSH
sudo ufw allow ssh
sudo ufw allow 22

HTTP on port 80, which is what unencrypted web servers use, using sudo ufw allow http or sudo ufw allow 80

HTTPS on port 443, which is what encrypted web servers use, using sudo ufw allow https or sudo ufw allow 443

Apache with both HTTP and HTTPS, using sudo ufw allow ‘Apache Full’

Nginx with both HTTP and HTTPS, using sudo ufw allow ‘Nginx Full’

Port Ranges

sudo ufw allow 6000:6007/tcp
sudo ufw allow 6000:6007/udp
sudo ufw allow from 203.0.113.4 to any port 22

Interfaces

sudo ufw allow in on eth0 to any port 80

Denying

sudo ufw deny http
sudo ufw deny from 203.0.113.4

Delete Rule

sudo ufw status numbered
sudo ufw delete 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment