Advanced Firewall Management for Linux Servers
✨ Zero-Config Setup: AFW automatically detects your network interface and SSH port during installation. Conflicting firewalls (UFW, firewalld) are disabled on fresh install only.
curl -fsSL https://irtec.github.io/afw-repo/pubkey.asc | sudo gpg --dearmor -o /usr/share/keyrings/afw.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/afw.gpg] https://irtec.github.io/afw-repo stable main" | sudo tee /etc/apt/sources.list.d/afw.list sudo apt update && sudo apt install afw
sudo curl -fsSL https://irtec.github.io/afw-repo/afw.repo -o /etc/yum.repos.d/afw.repo sudo rpm --import https://irtec.github.io/afw-repo/pubkey.asc sudo dnf install afw
sudo add-apt-repository ppa:irya31/afw sudo apt update && sudo apt install afw
After installation, your firewall is automatically configured and active!
After installation, AFW is already configured and running! No manual setup needed.
sudo afw
Launches the interactive menu with 12 options — navigate with arrow keys.
sudo afw setup
# If you need to change interface or SSH port sudo afw setup --interface eth0 --ssh-port 22
# Port management sudo afw port add tcp 80 sudo afw port add udp 53 sudo afw port add tcp 3000-4000 # range sudo afw port add tcp 8080 -s 10.0.0.5 # IP-restricted sudo afw port remove tcp 80 sudo afw port list # Port protection (rate limiting) sudo afw protect add 22 --rate 10 --per 60 sudo afw protect remove 22 # IP management sudo afw whitelist add 10.0.0.1 sudo afw blacklist add 1.2.3.4 # NAT / Masquerade sudo afw nat enable sudo afw nat disable # Port forwarding sudo afw forward add eth0 8080 80 # Firewall control sudo afw enable sudo afw disable sudo afw reload sudo afw status # Backup sudo afw backup create sudo afw backup list sudo afw backup restore /var/lib/afw/backups/state-20240101-120000.json
sudo systemctl enable afw # Auto-start on boot sudo systemctl start afw # Start firewall sudo systemctl stop afw # Stop firewall sudo systemctl reload afw # Reload rules sudo systemctl status afw # Check status
# APT (Debian/Ubuntu) sudo apt update && sudo apt upgrade -y # DNF (RHEL/Fedora/CentOS) sudo dnf upgrade -y
Config and rules are preserved. Reload after upgrade: sudo afw reload
GPL © irya