Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ????

share|improve this question

3 Answers 3

up vote 4 down vote accepted

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
share|improve this answer

To import an iptables script into your ruleset

iptables-restore < /path/to/firewall_script
share|improve this answer
    
Do I have to restart iptables once I type this command? –  Alex Sep 29 '09 at 6:43
1  
No, you shouldn need to restart –  JS. Sep 29 '09 at 6:51

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.