Yu-An, Chung
Computer Science and Information Engineering, National Taiwan University
"This module matches at a limited rate using a token bucket filter. A rule using this extension will continue matching until the limit is reached."
iptables -A INPUT -p icmp -s 127.0.0.1 -m limit --limit 6/m -j ACCEPT
load in the Limit Module
assign the matching rate
The rate can be:
>> iptables -A INPUT -p icmp -s 127.0.0.1 -m limit --limit 6/m -j ACCEPT
PING test (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=56 time=20.5 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=56 time=15.9 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=56 time=13.3 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=56 time=13.2 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=56 time=17.8 ms
64 bytes from 127.0.0.1: icmp_seq=11 ttl=56 time=14.2 ms
64 bytes from 127.0.0.1: icmp_seq=21 ttl=56 time=16.7 ms
64 bytes from 127.0.0.1: icmp_seq=31 ttl=56 time=17.5 ms
64 bytes from 127.0.0.1: icmp_seq=41 ttl=56 time=17.9 ms
64 bytes from 127.0.0.1: icmp_seq=51 ttl=56 time=16.1 ms
64 bytes from 127.0.0.1: icmp_seq=61 ttl=56 time=14.7 ms
64 bytes from 127.0.0.1: icmp_seq=71 ttl=56 time=13.2 ms
64 bytes from 127.0.0.1: icmp_seq=81 ttl=56 time=15.7 ms
In this example, ping sent an icmp package 1 time per second ...
iptables INPUT -p icmp -s 127.0.0.1 -m limit --limit 6/m --limit-burst 9 -j ACCEPT
--limit-burst works as an decumulator, it decreases by 1 when any input package matches the rule.
When --limit-burst becomes 0, the rate mechanism (flow control) mentioned previously will then take the charge.
By Yu-An, Chung