- 论坛徽章:
- 0
|
本帖最后由 isohybrid 于 2013-05-31 17:11 编辑
iptables
limit
This module matches at a limited rate using a token bucket filter. A rule using this extension will match until this limit is reached. It can be used in combination with the LOG target to
give limited logging, for example.
xt_limit has no negation support - you will have to use -m hashlimit ! --hashlimit rate in this case whilst omitting --hashlimit-mode.
--limit rate[/second|/minute|/hour|/day]
Maximum average matching rate: specified as a number, with an optional `/second', `/minute', `/hour', or `/day' suffix; the default is 3/hour.
限制匹配数据包的频率或速率,看清楚了,它是用来限制匹配的数据包的频率和速率的.这里“limit”这个词经常给别人“限制”的误解, 其实准确说,应该是“按一定速率去匹配”,至于“限制”还是“放行”是后面 -j 动作来实现的,limit 仅仅是个 match 模块,他的功能是匹配,匹配方式是按一定速率.
用iptables的limit模块,目标是ACCEPT.当你设置300/s时,它大约每3ms发出一个令牌,获得令牌的包可以发出去,没有获得令牌的包只能等待下一个令牌到来,这样不会造成一些包丢失,更不会造成所谓“断线”的.
限制某IP的上传速度为2000KB/秒(16Mbps,流入服务器带宽),即在此IP所在的服务器或VPS上wget的速度
iptables -A FORWARD -m limit -d 208.8.14.53 --limit 1400/s --limit-burst 100 -j ACCEPT
iptables -A FORWARD -d 208.8.14.53 -j DROP
2000kb/s和1400/s是怎么换算的呢 |
|