Interview Prep/Networking/Security: Firewalls, SGs, NACLs & VPN

How do you make iptables rules survive a reboot and avoid locking yourself out?

IntermediateScenarioSecurity: Firewalls, SGs, NACLs & VPN
Answer

Situation read → Rules in memory vanish and mistakes on remote hosts cut your session.

What I'd do →

  1. Apply rules while keeping an escape: iptables -A INPUT -p tcp --dport 22 -j ACCEPT before setting -P INPUT DROP
  2. Use a timed rollback: (sleep 120; iptables -F; iptables -P INPUT ACCEPT) & then cancel it once verified
  3. Save with iptables-save > /etc/iptables/rules.v4 and netfilter-persistent
  4. Prefer nftables or config management
  5. Keep console access

Why → Rule order and default policy decide whether you can still log in.

Interview tip → Say always allow ESTABLISHED,RELATED and SSH first.

All Networking questions Roadmap: Networking for DevOps

More on Security: Firewalls, SGs, NACLs & VPN