Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Latest commit

 

History

History
57 lines (50 loc) · 1.83 KB

README.md

File metadata and controls

57 lines (50 loc) · 1.83 KB

Firewalling Pterodactyl (or any other project that uses docker)

Manual installation (recommended)

Modify the UFW configuration file /etc/ufw/after.rules and add the following rules at the end of the file:

# --- DOCKER ---
*filter
:ufw-user-forward - [0:0]
:ufw-docker-logging-deny - [0:0]
:DOCKER-USER - [0:0]
-A DOCKER-USER -j ufw-user-forward

-A DOCKER-USER -j RETURN -s 10.0.0.0/8
-A DOCKER-USER -j RETURN -s 172.16.0.0/12
-A DOCKER-USER -j RETURN -s 192.168.0.0/16

-A DOCKER-USER -p udp -m udp --sport 53 --dport 1024:65535 -j RETURN

-A DOCKER-USER -j ufw-docker-logging-deny -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -d 192.168.0.0/16
-A DOCKER-USER -j ufw-docker-logging-deny -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -d 10.0.0.0/8
-A DOCKER-USER -j ufw-docker-logging-deny -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -d 172.16.0.0/12
-A DOCKER-USER -j ufw-docker-logging-deny -p udp -m udp --dport 0:32767 -d 192.168.0.0/16
-A DOCKER-USER -j ufw-docker-logging-deny -p udp -m udp --dport 0:32767 -d 10.0.0.0/8
-A DOCKER-USER -j ufw-docker-logging-deny -p udp -m udp --dport 0:32767 -d 172.16.0.0/12

-A DOCKER-USER -j RETURN

-A ufw-docker-logging-deny -m limit --limit 3/min --limit-burst 10 -j LOG --log-prefix "[UFW DOCKER BLOCK] "
-A ufw-docker-logging-deny -j DROP

COMMIT

Restart UFW (warning: after restart public networks can't access any published docker ports)

sudo systemctl restart ufw

Opening docker ports

ufw route allow proto tcp from any to any port 20010
ufw route allow proto tcp from 172.17.0.2 to any port 20010

Installation using script

Clone this repo

git clone https://github.com/oqo0/firewalling-pterodactyl.git

Make an executable script

chmod u+x install.sh

Run the script

sudo ./install.sh

Script creates a backup copy at /etc/ufw/after.rules.copy.