Skip to content

Instantly share code, notes, and snippets.

@craig-m-unsw
Last active October 17, 2022 10:00
Show Gist options
  • Save craig-m-unsw/2e1e467a2c25ad0f7a4ccb33a0ffba5b to your computer and use it in GitHub Desktop.
Save craig-m-unsw/2e1e467a2c25ad0f7a4ccb33a0ffba5b to your computer and use it in GitHub Desktop.
Uncomplicated Firewall example

ufw (Uncomplicated Firewall) example setup

install from ufw if missing:

sudo dnf install -y ufw
sudo apt install -y ufw

default deny

ufw default deny outgoing
ufw default deny incoming

Inbound rules:

# allow 8080 from any
ufw allow 8080/tcp
# allow ssh from local subnet
ufw allow from 192.168.1.0/24 to any port 22 proto tcp

Limited outbound:

ufw allow out 80,443/tcp # http/s
ufw allow out 53,123/tcp # dns, ntp
ufw allow out 53,123/udp # dns, ntp
ufw allow out 67,68/udp # dhcp
# outbound mysql to DB server IP
ufw allow out from any to 192.168.2.2 port 3306 proto tcp

finish up

ufw enable
ufw logging on
ufw status verbose

ufw links

misc

not ufw.

route blackholes, these will not persist after reboot:

ip route add blackhole 10.0.0.0/8
ip route add blackhole 172.16.0.0/12
ip route add blackhole 192.168.0.0/16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment