Linux Firewall – How to Test Iptables Rules to Prevent Remote Lockout

iptableslinux

As I'm learning about iptables I've made a couple of mistakes and locked myself out.

What method(s) do you use to test rules without locking yourself out?

I'm using ubuntu server 12.04 LTS


All the answers below were helpful. In the end I used a combination of options. It also helps to have IPMI access to your remote server just in case! But ideally test the rules locally on a replicated environment and test that first. Vagrant helps in this regard to get test setups working quickly.

Best Answer

iptables-apply is specifically designed for this. It applies your rules, and then prompts you to affirm. If you don't affirm, it rolls them back out. So if you brick the system or lock yourself out with apply, it rolls back.