To save iptables firewall rules permanently on a Linux system, you can use the iptables-save
command to save the rules to a file, and then use the iptables-restore
command to load the rules from the file when the system is started.
iptables-save
command. For example:iptables-save > /etc/iptables/rules.v4
This will save the iptables rules to the file /etc/iptables/rules.v4
.
iptables-restore < /etc/iptables/rules.v4
chmod
command. For example:chmod +x /path/to/script.sh
/etc/init.d
directory or by adding the script to the system startup scripts.Keep in mind that the method for saving and restoring iptables rules may vary depending on the Linux distribution you are using. Consult the documentation for your Linux distribution for more information on how to save and restore iptables rules permanently.
You can also use other tools such as iptables-persistent
or firewalld
to save and restore iptables rules on a Linux system. These tools can simplify the process of saving and restoring iptables rules, and may be easier to use depending on your needs. Consult the documentation for these tools for more information on how to use them to save and restore iptables rules.