My system admin gave me a file with iptables rules. What command do I type in to load this?
I watched him do it before, and he did it in 1 line! Something like...iptables > thefile.dat ????
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
iptables-restore < http://git.company.com/Company/iptables-rules/blob/master/iptables-rules.txt
– Jay Jun 06 '17 at 23:28
eg:
– Jay Jun 06 '17 at 23:29iptables-restore < http://git.company.com/Company/iptables-rules/blob/master/iptables-rules.txtcurl -s SOME_URL | iptables-restore. – samthecodingman Jun 13 '17 at 08:02teedoes is write to both stdout and a file at the same time. You certainly don't need to use it. – Eric Haynes Jul 03 '18 at 02:06iptables-applyinstead. It safeguards you from accidental lock-out. – jchook Sep 04 '19 at 21:32