How to Save and Restore the Iptables rule and configuration from file?
If you want to modify the configuration and rules, so you must save the current configuration to a file.
So step one is to save the rules configuration by typing the following commands:
$ sudo iptables-save &gt; /root/my-iptables.rules

To restore it just use the command iptables-restore:
$ sudo iptables-restore &lt; /root/my-iptables.rules

⚠️ When you changed the existing rules after saving the file, You should save it again or change the existing file and restore it from the file.