How to Backup Iptables Configuration
It is important to Know how to backup iptables firewall rules on your Linux server. Iptables firewall is a very sensitive thing, with one mistake you could mess up your entire network system, especially if you have configured your Linux server as a router. So you should always backup current configuration before you make any changes.
iptables-save command use to backup iptables with output redirection.
iptables-save > backup-file-name
If you want, you can append the current date to the end of the filename to make it unique every time and to know which day backup was created.
iptables-save > /root/iptables-backup-$(date +%F)
iptables-restore command is used to restore to old configuration from a backup file.
iptables-restore < backup-file-name
Configure Automatic Backup
We can add a cron job to backup iptables automatically at a given time. So You do not have to do it manually every time.
0 0 * * * root iptables-save > /root/iptables-backup-$(date +%F)
Add Above Cronjob to /etc/crontab file. Iptables backup will run everyday midnight with a unique name by day.