Emergency CheatsheetCODE: 028-IPTABLES-UFW-FIREWALL⏱️ ~11 min read
iptables & UFW Practical Firewall: Port Management, IP Blocking & NAT Cheatsheet
Production firewall handbook: default deny rules, rate-limiting SSH brute force, IP whitelisting, and Docker iptables coexistence.
Authored by: Vibe DevOps · Published: 11/2/2026
In cloud infrastructure and Linux hosts, the firewall serves as the first line of defense against automated vulnerability scanners, SSH brute-force bots, and DDoS floods. Essential triage commands for both iptables and UFW.
1. Inspecting Rules and Packet Counters
sudo iptables -vnL --line-numbers
sudo ufw status numbered
conntrack -C
iptables -vnL --line-numbers: Displays packet (pkts) and byte counters to verify that rules actively match real traffic.ufw status numbered: Shows numbered firewall rules for safe insertion and removal.conntrack -C: Checks connection tracking table saturation to diagnose packet drops.
2. Managing Service Ports
sudo ufw allow 443/tcp
sudo ufw limit 22/tcp
sudo ufw delete allow 8080/tcp
3. Blocking Malicious Attackers
sudo iptables -I INPUT 1 -s <attacker-ip> -j DROP
sudo ufw insert 1 deny from <attacker-ip>
4. NAT and Port Forwarding
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
💡 Team Storage & Usage Tips
Store the vector PDF in your internal team repository (Notion, Confluence) or print it out in A4 format next to your workstation for rapid troubleshooting during midnight production outages.