Robert Klemme
7/27/2007 2:00:00 PM
2007/7/27, Marcin Tyman <m.tyman@interia.pl>:
> Guys,
> I'm going to search for iptables entries for some IP's. The worst thing
> is that rules in iptables can be each time in different order. I need to
> check whether all desired rules for particular IP are in iptables.
> Moreover I need to find out if there are no more entries than expected.
>
> Assume that a, b, c, d etc.. represent one line in iptable (one entry -
> a for IP = x.x.x.x, b for y.y.y.y etc). I need to check whether 3 (not
> only one and no more than 3) rules for ip x.x.x.x are in iptables but
> these rules (lines) each time may be in different positions (other rules
> may be placed between them etc...)
I would not do any sorting here. Rather I'd fill a Hash with IPs as
keys and arrays of rules as values. That way you do not have to
bother with ordering and also it's faster (probably not an issue in
your case). If you just want to count rules then you only need a
counter as value.
Kind regards
robert