This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:firewall:ufw [2022/07/27 13:24] gcooper |
networking:firewall:ufw [2022/07/28 13:44] (current) gcooper |
||
---|---|---|---|
Line 2: | Line 2: | ||
UFW is the default firewall configuration tool on Ubuntu and is simple to install on Debian. | UFW is the default firewall configuration tool on Ubuntu and is simple to install on Debian. | ||
+ | |||
+ | https:// | ||
**Getting Started**: https:// | **Getting Started**: https:// | ||
Line 14: | Line 16: | ||
ufw default deny incoming | ufw default deny incoming | ||
ufw default allow outgoing | ufw default allow outgoing | ||
- | ufw allow 22/tcp #SSH from everywhere | + | ufw allow 2222/tcp #Example |
ufw --force enable | ufw --force enable | ||
- | ufw status | + | ufw status |
</ | </ | ||
+ | |||
+ | ===== Custom Rules ===== | ||
+ | |||
+ | FIXME This needs further confirmation. | ||
+ | |||
+ | <note warning> | ||
+ | |||
+ | <note important> | ||
+ | |||
+ | < | ||
+ | vim / | ||
+ | </ | ||
+ | |||
+ | Insert the lines mentioning Docker, in the locations shown. | ||
+ | |||
+ | < | ||
+ | # | ||
+ | # rules.input-after | ||
+ | # | ||
+ | # Rules that should be run after the ufw command line added rules. Custom | ||
+ | # rules should be added to one of these chains: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # Don't delete these required lines, otherwise there will be errors | ||
+ | *filter | ||
+ | : | ||
+ | : | ||
+ | : | ||
+ | : | ||
+ | # End required lines | ||
+ | |||
+ | # Custom rules for Docker apps | ||
+ | -A DOCKER-USER -i eth0 -m conntrack --ctstate RELATED, | ||
+ | -A DOCKER-USER -i eth0 -m conntrack --ctstate INVALID -j DROP | ||
+ | -A DOCKER-USER -i eth0 --match multiport -p tcp --dports 80, | ||
+ | -A DOCKER-USER -i eth0 --match multiport -p udp --dports 22116 -j ACCEPT | ||
+ | -A DOCKER-USER -i eth0 --match multiport -p tcp --dports 81,9443 --source 192.168.1.0/ | ||
+ | -A DOCKER-USER -i eth0 -m conntrack --ctstate NEW -j LOG --log-prefix " | ||
+ | -A DOCKER-USER -i eth0 -m conntrack --ctstate NEW -j DROP | ||
+ | |||
+ | # don't log noisy services by default | ||
+ | -A ufw-after-input -p udp --dport 137 -j ufw-skip-to-policy-input | ||
+ | -A ufw-after-input -p udp --dport 138 -j ufw-skip-to-policy-input | ||
+ | -A ufw-after-input -p tcp --dport 139 -j ufw-skip-to-policy-input | ||
+ | -A ufw-after-input -p tcp --dport 445 -j ufw-skip-to-policy-input | ||
+ | -A ufw-after-input -p udp --dport 67 -j ufw-skip-to-policy-input | ||
+ | -A ufw-after-input -p udp --dport 68 -j ufw-skip-to-policy-input | ||
+ | |||
+ | # don't log noisy broadcast | ||
+ | -A ufw-after-input -m addrtype --dst-type BROADCAST -j ufw-skip-to-policy-input | ||
+ | |||
+ | # don't delete the ' | ||
+ | COMMIT | ||
+ | </ | ||
+ | |||