ufw
Table of Contents
- 1. Show status
- 2. Explicitly set default to deny incoming
- 3. Allow connections from specific IP to defined port
- 4. Allow connections from specific IP to multiple ports
- 5. Allow connections from any IP to defined port
- 6. Allow connections from IP range to any IP on a port range
- 7. Applications profiles
- 8. Deleting rules
- 9. Enabling ufw
- 10. Docker
- 11. Rate limiting
- 12. References
1. Show status
2. Explicitly set default to deny incoming
ufw default deny incoming
3. Allow connections from specific IP to defined port
ufw allow from 192.168.0.3 proto tcp to any port 1234
4. Allow connections from specific IP to multiple ports
ufw allow from 192.168.0.3 to any port 1234,5678 proto tcp
5. Allow connections from any IP to defined port
ufw allow proto tcp from any to any port 1234
6. Allow connections from IP range to any IP on a port range
ufw allow from 192.168.0.0/16 to any port 1230:1240 proto tcp
7. Applications profiles
The profiles are kept in /etc/ufw/applications.d
7.1. To view which applications have installed a profile
ufw app list
7.2. Allow connections from IP range to an application profile
There is no need to provide the protocol (e.g. proto tcp)
ufw allow from 192.168.0.0/16 to any app syncthing-gui
8. Deleting rules
To delete a rule find its associated number
ufw status numbered
Then to delete the rule
ufw delete <number>
9. Enabling ufw
ufw enable systemctl enable --now ufw
10. Docker
11. Rate limiting
- https://wiki.archlinux.org/title/Uncomplicated_Firewall#Rate_limiting_with_ufw
- https://manpages.debian.org/stable/ufw/ufw.8
ufw supports connection rate limiting, which is useful for protecting against brute-force login attacks. When a limit rule is used, ufw will normally allow the connection but will deny connections if an IP address attempts to initiate 6 or more connections within 30 seconds.