Wednesday, April 26, 2023

Backing Up and Restoring iptables Rules

To backup iptables rules, we can use iptables-save command. This command is to save current iptables rules into a file called iptables.backup
sudo iptables-save > iptables.backup

To restore, simply use iptables-restore. This command is to restore iptables rules from a backup file called iptables.backup
sudo iptables-restore iptables.backup

We can also test the backup file, before committing the ruleset to sytem
sudo iptables-restore -tv iptables.backup

Where -t is for testing, and -v is for verbose.

No comments: