Skip to contentSkip to conversation

-m limit problem

DISCUSSION Darius Tribandis 2 participants 4 messages Sep 20, 2004 – Sep 21, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

i try explain it with examples...

/usr/sbin/iptables -t nat -N httpinfo
/usr/sbin/iptables -t nat -A PREROUTING -p tcp -s USERIP -m mac --mac-source AA:AA:BB:BB:CC:CC -m multiport --destination-port 80,8080,3128 -j httpinfo /usr/sbin/iptables -t nat -A httpinfo -p tcp -s 10.5.4.14 -m limit --limit 1/day --limit-burst 1 -j DNAT --to LOCALIP:5454

after that it acts ok. 1 time per day i will get redirected.

sometimes i nead some times per day do like this:

/usr/sbin/iptables -t nat -F PREROUTING
/usr/sbin/iptables -t nat -A PREROUTING -p tcp -s USERIP -m mac --mac-source AA:AA:BB:BB:CC:CC -m multiport --destination-port 80,8080,3128 -j httpinfo

here problem begins.
i am not modifaing httpinfo table but i geting redirect after every reload like this.

Can anyone help with this

Thanks
---
D. Tribandis
Kaunas University of Technology
Institute of Information Technology Development

#1 lore raw
Quoted 8 lines · Darius Tribandis

/usr/sbin/iptables -t nat -N httpinfo
/usr/sbin/iptables -t nat -A PREROUTING -p tcp -s USERIP -m mac --mac-source AA:AA:BB:BB:CC:CC -m multiport --destination-port 80,8080,3128 -j httpinfo /usr/sbin/iptables -t nat -A httpinfo -p tcp -s 10.5.4.14 -m limit --limit 1/day --limit-burst 1 -j DNAT --to LOCALIP:5454

sometimes i nead some times per day do like this:

Quoted 7 lines

/usr/sbin/iptables -t nat -F PREROUTING
/usr/sbin/iptables -t nat -A PREROUTING -p tcp -s USERIP -m mac --mac-source AA:AA:BB:BB:CC:CC -m multiport --destination-port 80,8080,3128 -j httpinfo

here problem begins.
i am not modifaing httpinfo table but i geting redirect after every reload like this.

Due to the way limit stores it's counters the counters are reset each time you modify the ruleset in the same table (nat in your case).

In theory it may be possible to modify the iptables kernel API to allow limit to keep it's counters while modifying the iptable, but in reality the best method is to modify limit to keep it's counters in a more sane place than within the iptable matchdata.. (or more realistic, write an alternative match implementation using separate counters).

Regards
Henrik

#2 lore raw

hi,

Now i understand. I thing that counter resets just after i reload specific rule, but if it resets each time i modify any of rules =- than it must by trated as bug, because it lacks all funcionality of iptables limit match module.

is it posible to owercome this "future" ? ;)

---
D. Tribandis
Kaunas University of Technology
Institute of Information Technology Development

----- Original Message -----
From: "Henrik Nordstrom" <[email protected]>
To: "Darius Tribandis" <[email protected]>
Cc: <[email protected]>
Sent: Tuesday, September 21, 2004 12:52 AM
Subject: Re: -m limit problem

Quoted 4 lines · Darius Tribandis
Quoted 3 lines

/usr/sbin/iptables -t nat -N httpinfo /usr/sbin/iptables -t nat -A PREROUTING -p tcp -s USERIP -m

mac --mac-source

Quoted 1 line
Quoted 1 line

AA:AA:BB:BB:CC:CC -m multiport --destination-port 80,8080,3128 -j

httpinfo

Quoted 1 line
Quoted 1 line

/usr/sbin/iptables -t nat -A httpinfo -p tcp -s 10.5.4.14 -m

limit --limit

Quoted 6 lines
Quoted 6 lines

1/day --limit-burst 1 -j DNAT --to LOCALIP:5454

sometimes i nead some times per day do like this:

/usr/sbin/iptables -t nat -F PREROUTING /usr/sbin/iptables -t nat -A PREROUTING -p tcp -s USERIP -m

mac --mac-source

Quoted 1 line
Quoted 1 line

AA:AA:BB:BB:CC:CC -m multiport --destination-port 80,8080,3128 -j

httpinfo

Quoted 3 lines
Quoted 3 lines

here problem begins.
i am not modifaing httpinfo table but i geting redirect after every

reload

Quoted 13 lines
Quoted 1 line

like this.

Due to the way limit stores it's counters the counters are reset each time you modify the ruleset in the same table (nat in your case).

In theory it may be possible to modify the iptables kernel API to allow limit to keep it's counters while modifying the iptable, but in reality the best method is to modify limit to keep it's counters in a more sane place than within the iptable matchdata.. (or more realistic, write an alternative match implementation using separate counters).

Regards
Henrik

#3 lore raw
Quoted 4 lines · Darius Tribandis

Now i understand. I thing that counter resets just after i reload specific rule, but if it resets each time i modify any of rules =- than it must by trated as bug, because it lacks all funcionality of iptables limit match module.

It is when you touch any rule within the same table (nat in your case).

No it is not a bug, it is a limitation of iptables.

Quoted 1 line

is it posible to owercome this "future" ? ;)

Only by redesign of iptables to allow the limit match to save it's counters in the user copy of the table, not the first CPU copy.

The pkttables approach worked on by Harald will solve this problem as it does not reload the whole table on every change.

Regards
Henrik