I have a file with all the iptable settings. How do I load this into my server?

My system admin gave me a file with iptables rules. What command do I type in to load this?

iptables-restore < file-with-iptables-rules.txt

I watched him do it before, and he did it in 1 line! Something like...iptables > thefile.dat ????

iptables-save > file-with-iptables-rules.txt

You load an iptables configuration file using iptables-restore

iptables-restore thefile.dat

This has effect immediately. However for this settings to be persistent over system reboot they must be saved. On most distributions this can be done with.

/etc/init.d/iptables save

As mentioned in other answers the configuration can be saved using

iptables-save > thesavefile.dat

The file itself is a text file and can be edited with any texteditor and then reloaded into iptables using the iptables-restore command.


To import an iptables script into your ruleset

iptables-restore < /path/to/firewall_script