UFW – Uncomplicated Firewall
How to install and configure UFW on Ubuntu.
Download and install UFW
apt update && apt upgrade && apt -y install ufw
Status
ufw status
Status: inactive
Open ports
ufw allow 22,80,443/tcp
Allow all for local net
vi /etc/ufw/before.rules
After the line
# End required lines
add the rule
-A ufw-before-input -s 192.168.0.0/24 -j ACCEPT
For IPv6 add the rule(s) to before6.rules
Install UFW as service
ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
Logging
ufw logging on ufw logging off
tail -f /var/log/ufw.log
Logging levels
low = Standard
ufw logging low ufw logging medium ufw logging high ufw logging full
Disable UFW
ufw disable
Firewall stopped and disabled on system startup
Reload UFW
ufw reload
Display rules
ufw status numbered
iptables -L -n