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

I have these iptables rules

# Generated by iptables-save v1.4.10 on Thu Oct  6 17:16:01 2011
*filter
:INPUT ACCEPT [22517:2222881]
:FORWARD ACCEPT [2:176]
:OUTPUT ACCEPT [16961:69145734]
COMMIT
# Completed on Thu Oct  6 17:16:01 2011
# Generated by iptables-save v1.4.10 on Thu Oct  6 17:16:01 2011
*nat
:PREROUTING ACCEPT [29:3325]
:INPUT ACCEPT [18:2668]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 192.168.245.0/24 -j MASQUERADE 
COMMIT
# Completed on Thu Oct  6 17:16:01 2011

They are generated from iptables-save.

I would like to have these rules as iptables commands that I can launch in a script instead.

How do I "convert" these rules to iptables commands?

share|improve this question
    
What is your final goal? –  quanta Oct 20 '11 at 11:14

1 Answer 1

up vote 4 down vote accepted

You do know that you can apply the ruleset by iptables-restore < yourrules.conf?
add the -c option to restore all counters.

You can export the rules with iptables-xml

I found this script and it seems to do the job.

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.