LoginSignup
5
4

More than 5 years have passed since last update.

iptablesによる帯域制限の上限に関して

Posted at

iptableでパケットの帯域制限を行う場合、
下記のようにhashlimitで指定しますが
ここに10,000/sec以上の値を設定しても効きない理由を調べてみました。

iptables -A INPUT -j ACCEPT -m hashlimit --hashlimit 1000/sec --hashlimit-burst 1000 --hashlimit-name limit-in
iptables -A INPUT -j REJECT

下記のようにlibxt_hashlimit.cでXT_HASHLIMIT_SCALEを超えるとエラーするようになっていて
XT_HASHLIMIT_SCALEが10,000で設定されておりました。

libxt_hashlimit.c
static
int parse_rate(const char *rate, u_int32_t *val)
{
     **略**   
    /* This would get mapped to infinite (1/day is minimum they
           can specify, so we're ok at that end). */
    if (r / mult > XT_HASHLIMIT_SCALE)
        exit_error(PARAMETER_PROBLEM, "Rate too fast `%s'\n", rate);

    *val = XT_HASHLIMIT_SCALE * mult / r;
    return 1;
}
xt_hashlimit.h
/* timings are in milliseconds. */
#define XT_HASHLIMIT_SCALE 10000
/* 1/10,000 sec period => max of 10,000/sec.  Min rate is then 429490
seconds, or one every 59 hours. */

ですので、iptableによる帯域制限は114Mbpsが上限となってしまうようです。

10,000pps * MTU(1500) * 8(bit) ≒ 114Mbps

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4