Ideal for developers, sysadmins, or anyone managing Linux servers.
π Introduction
Securing your Linux server is critical, especially when itβs exposed to the internet. One of the easiest and most effective tools to manage your server firewall is UFW (Uncomplicated Firewall).
In this guide, Iβll walk you through an interactive script I built that:
- Checks if UFW is installed and running
- Installs and enables it if needed
- Scans your firewall rules
- Identifies misconfigurations
- Suggests secure alternatives
- Optionally applies fixes (with care!)
Perfect for system admins, freelancers, or anyone running a VPS (e.g., AWS Lightsail, EC2, DigitalOcean, etc.).
π§ Features of the Script
β
Checks UFW status and installation
β
Suggests rules based on common security guidelines
β
Detects and warns about open dangerous ports (e.g., 22, 80 open to world)
β
Recommends changing default SSH port
β
Offers auto-fix with user confirmation
β
Supports IPv4 and IPv6 scanning
β
Logs findings for audit/compliance
π‘οΈ Example Recommendations:
- Change SSH Port:
sudo nano /etc/ssh/sshd_config
# Change Port 22 to 2222
sudo systemctl restart ssh
sudo ufw allow 2222/tcp
sudo ufw delete allow 22/tcp
β Try It!
git clone
https://github.com/mxkdevops/UFW-audit.git
cd ufw-audit-fixer
chmod +x ufw_audit.sh
sudo ./ufw_audit.sh
π Conclusion
This tool helps Linux admins detect firewall vulnerabilities quickly, with easy-to-understand advice and the option to fix issues securely. Itβs ideal for compliance audits, pentest prep, or day-to-day hardening.
Stay safe β automate wisely!