Networking Forums

Networking Forums > Computer Networking > Linux Networking > What is the limitation of iptables's limit option?

Reply
Thread Tools Display Modes

What is the limitation of iptables's limit option?

 
 
Nick Wu
Guest
Posts: n/a

 
      09-25-2003, 02:06 PM
Hi all,

I had added a rule to my linux box to prevent "Ping flooding".
Actually, i limit ICMP packet to be accepted 253 times at maximum
within a second by the limit extension option. The rule looks like
this
"ipatbles -t nat -A PREROUTING -p icmp --limit 253/s -j ACCEPT"
But when i use packet generator with sniffer to test this fucntion, it
doesn't always work. If i send each icmp packets with 10 millisecond
delay, it works fine, but when i doing this with each packet 3
millisecond delay, it seems crash(the rule doesn't match, only few
packets match this rule, other goes to next rules). It seems packets
are too fast to process by iptables and iptables can just handle
packets with time interval greater than 3 millisecond. Does this a
kernel timer issue or any ideas?


thanks for your comments.

Nick Wu
 
Reply With Quote
 
 
 
 
Adam Dyga
Guest
Posts: n/a

 
      09-25-2003, 09:03 PM
Nick Wu wrote:

> Hi all,
>
> I had added a rule to my linux box to prevent "Ping flooding".
> Actually, i limit ICMP packet to be accepted 253 times at maximum
> within a second by the limit extension option. The rule looks like
> this
> "ipatbles -t nat -A PREROUTING -p icmp --limit 253/s -j ACCEPT"
> But when i use packet generator with sniffer to test this fucntion, it
> doesn't always work. If i send each icmp packets with 10 millisecond
> delay, it works fine, but when i doing this with each packet 3
> millisecond delay, it seems crash(the rule doesn't match, only few
> packets match this rule, other goes to next rules).


And it works like it should work. "Limit" modulue allows to define how many
packets can hit the 'target' (after -j), if limit is exceeded the rule will
be passed over. The solution is easy: add one more rule (after yours) that
blocks all ICMP packets.
BTW why are you doing filtering in 'nat' table? This should be done in
'filter' table (INPUT or FORWARD chain).

--
Greets
adeon
 
Reply With Quote
 
Horst Knobloch
Guest
Posts: n/a

 
      09-26-2003, 07:10 AM
Nick Wu <(E-Mail Removed)> wrote:

> I had added a rule to my linux box to prevent "Ping flooding".
> Actually, i limit ICMP packet to be accepted 253 times at maximum
> within a second by the limit extension option. The rule looks like
> this
> "ipatbles -t nat -A PREROUTING -p icmp --limit 253/s -j ACCEPT"


Avoid filtering in "-t nat PREROUITNG" chain, use "-t filter
FORWARD and INPUT" instead.


> But when i use packet generator with sniffer to test this fucntion, it
> doesn't always work. If i send each icmp packets with 10 millisecond
> delay, it works fine, but when i doing this with each packet 3
> millisecond delay, it seems crash(the rule doesn't match, only few
> packets match this rule, other goes to next rules).


Your rule above means explicitly written:

.... -p icmp --limit 253/s --limit-burst 5 -j ACCEPT

I explain the limit extension always with a leaky bucket
analogy. In your case, the bucket can hold up to 5 packets
(--limit-burst) and the buckets leaks out 253 packets per
second (--limit).

So, if you send one packet each 10 ms the bucket does not fill
up because the packets leak out at a quicker rate (100 pkts
per second in vs. 253 pkts per second out). So the rule matches
for *each* incoming packet.

However if you send each 3 ms a packet the packets come in
quicker (333 pkts per second) than they leak out (253 pkts
per second). So the bucket fills up and overflows for the
first time after 60 ms. In this time 20 packets come in and
match the rule, but only 15 leak out.

So you get the following sequence:
20 packets match, 1 packet doesn't match, 3 packets match,
1 packet doesn't match, 3 packets match, etc

See also following link
http://www.netfilter.org/documentati...g-HOWTO-7.html


Note that if a limit rule does not match, the packet is
*not* automatically rejected; iptables just inspects the
next rule as usual. Thus, if you want to rate limit you
need something like

iptables -N ICMP_FLOOD_CHECK
iptables -A ICMP_FLOOD_CHECK --limit 253/s -j ACCEPT
iptables -A ICMP_FLOOD_CHECK -j DROP

iptables -A INPUT -p icmp -j ICMP_FLOOD_CHECK
iptables -A FORWARD -p icmp -j ICMP_FLOOD_CHECK


HTH

Ciao, Horst
--
»When pings go wrong (It hurts me too)« E.Clapton/E.James/P.Tscharn
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Would using iptables limit my number of possible hops? dominic.jacobssen@gmail.com Linux Networking 10 09-01-2007 11:57 PM
iptables -m limit question Matt Linux Networking 1 05-13-2005 02:16 PM
IPTABLES limit bandwidth? Supercell Linux Networking 3 03-14-2005 12:47 PM
iptables to limit access to pop3 - how? Rene Madsen Linux Networking 1 09-02-2003 12:00 PM
IPTABLES STRING PATCH LIMITATION WsWi Linux Networking 1 08-22-2003 11:21 AM



1 2 3 4 5 6 7 8 9 10 11