All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mart Frauenlob <mart.frauenlob@chello.at>
To: netfilter@vger.kernel.org
Cc: rk@dat.cz
Subject: Re: iptables rules in comparable form
Date: Tue, 01 Jun 2010 11:18:55 +0200	[thread overview]
Message-ID: <4C04D07F.6040702@chello.at> (raw)
In-Reply-To: <alpine.LSU.2.01.1006011043190.3431@obet.zrqbmnf.qr>

On 01.06.2010 10:50, jengelh@medozas.de wrote:
> On Tuesday 2010-06-01 10:10, Radek Kanovsky wrote:
> 
>> Hello,
>>
>> is there some way to get iptables rules in some normalized form?
>> What I mean is normalized or canonical form that is convenient
>> for rule comparison.
> 
> Load em up, then use iptables-save and/or iptables -S.
> 
>> When I want update rules on firewall or router with thousands of rules
>> I want to do it incrementaly. Reloading whole iptables on small change
>> every ten minutes is not acceptable because it takes very long time
> 
> That's because you are not using iptables-restore to do an O(n) reload. 
> 
> Calling iptables again and again is going to replace tables over and 
> over.
> 
>> and resets counters defined for accounting purposes. But incremental
>> solution requires some comparable rule form so machine can decide
>> which rule already exists, which is new and which should be deleted.


Besides there's also iptables-xml (not sure when it came up), which can
give you a unified output. Reading man iptables-xml the way back is
possible like:
Conversion from XML to iptables-save format may be done using the
iptables.xslt script and xsltproc, or a custom program using libxsltproc
or similar;  in this fashion:

       xsltproc iptables.xslt my-iptables.xml | iptables-restore

>>
>> I have prototype in python that does such normalization and is able
>> to output "patch" for existing rules according to given new rules.
>> Script generates -N/-X/-F/-P/-I/-D/-A rules via standard python difflib
>> and is pretty effective and simle (90 lines) but requires rules in
>> comparable form and this is the harder part of my problem (2662 lines).

I bet python has loads of xml libs.

[...]

Best regards

Mart



  reply	other threads:[~2010-06-01  9:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-01  8:10 iptables rules in comparable form Radek Kanovsky
2010-06-01  8:50 ` Jan Engelhardt
2010-06-01  9:18   ` Mart Frauenlob [this message]
2010-06-01 11:25     ` Radek Kanovsky
2010-06-01 11:56       ` Jan Engelhardt
2010-06-01 16:03         ` Radek Kanovsky
2010-06-01 18:19           ` Jan Engelhardt
2010-06-01 18:35             ` Radek Kanovsky
2010-06-01 18:01         ` Radek Kanovsky
2010-06-01 18:26           ` Jan Engelhardt
2010-06-01 19:36             ` Radek Kanovsky
2010-06-01 20:29               ` Pieter Smit
2010-06-02  6:17                 ` Radek Kanovsky
2010-06-01 13:27       ` Mart Frauenlob
2010-06-01 16:47         ` Radek Kanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C04D07F.6040702@chello.at \
    --to=mart.frauenlob@chello.at \
    --cc=netfilter@vger.kernel.org \
    --cc=rk@dat.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.