0

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?

1
  • What is your final goal?
    – quanta
    Oct 20, 2011 at 11:14

1 Answer 1

4

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .