When your server shutsdown (halts), reboots, or enters runlevel 1, your iptables configuration is automatically wiped and reset. Packages such as iptables-persistent supposedly help with this problem, but unless you save your rules manually, the rules are never saved automatically when the system reboots.

I've wanted to truly persist my iptables, so I decided to change their package to always save the iptables rules when the system reboots, halts, or enters runlevel 1 automatically. The rules are then restored when the system boots to runlevels 2-5. This means that your iptables configuration will persist forever. This may not be desired, but if I ban an IP address permanently, I always want it to be banned.

If you'd like to use this modified version of iptables-persistent so that your rules are automatically saved on shutdown, you can install it by running the below commands: