Restore iptables rules from a backup
how to restore iptables rules | iptables-restore from file | roll back firewall changes | iptables | backup | firewallWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
iptables-restore --test < /root/iptables-2026-10-09-1200.rules && iptables-restore < /root/iptables-2026-10-09-1200.rulesFirst checks the file with --test without changing anything, and only loads it if the syntax is valid. All rules of the tables contained in the file are replaced completely. Rules added since the backup, for example by Fail2Ban, are gone afterwards.
Note: If the backup does not allow SSH, the server is no longer reachable via SSH after loading it. Restart Fail2Ban afterwards so it recreates its chains.
Also searched as
- how to restore iptables rules
- iptables-restore from file
- roll back firewall changes