Iptables – Safely changing iptables firewall rules

iptables

What do people do when they are changing their firewall rules to make sure they don't accidentally lock themselves out?

For example, is there a way to load firewall rules so that they're only active for some testing period and then have the firewall rules revert back to the previous settings?

Best Answer

Another option would be to have a screen session open on the server, and have a job in the screen session that sleeps for a few minutes and then flushes the tables. After you have made your changes, you can just kill the job. You could also maybe just have the script change the INPUT policy to ACCEPT, or something like that.

Might be a little more convenient than cron, but the same idea. I do a similar thing with routers reload in 10. So if I lock myself out, the router will reboot and restore the config to the state before I made the change.