Chinaunix
标题:
关于iptables hashlimit 限速
[打印本页]
作者:
300second
时间:
2011-04-19 11:09
标题:
关于iptables hashlimit 限速
下面这段脚本研究了好久都没弄明的,在这里问问大家
eth1(公网接口) eth0 (内网接口)
首先自定义一条链
#this's for
#init user-define chain
iptables -N BASE
iptables -t filter -A FORWARD -i eth0 -s 0/0 -p all -m state --state NEW,ESTABLISHED,RELATED -j BASE
iptables -t filter -A BASE -m hashlimit --hashlimit-name spe_base --hashlimit-mode srcip --hashlimit 100/sec -j ACCEPT
iptables -t filter -A BASE -j DROP
然后再在filter 表中的FORWARD 对各ip 进行限速
iptables -t filter -A FORWARD -i eth1 -s 0/0 -o eth0 -d 192.168.5.1 -p all -m limit --limit 150/s -j ACCEPT
#iptables -t filter -A FORWARD -i eth1 -s 0/0 -o eth0 -d 192.168.5.2 -p all -m limit --limit 150/s -j ACCEPT
#iptables -t filter -A FORWARD -i eth1 -s 0/0 -o eth0 -d 192.168.5.3 -p all -m limit --limit 150/s -j ACCEPT
iptables -t filter -A FORWARD -i eth1 -s 0/0 -o eth0 -d 192.168.5.5 -p all -m limit --limit 150/s -j ACCEPT
对于上面的问题有两个问题不是很明白
1) 从eth0 在进方向state 的NEW,ESTABLISHED,RELATED 没有作出明确的放行,只在自定义链中放行,这样能通信吗? 本人做实验的时候没有成功
2) 在实现限速的时候是用hashlimit 和值限速还是用limit 的值限速
希望在这里得到大家的答案........
作者:
zjfdamo
时间:
2011-04-19 16:17
刚仔细看了下 没弄懂 不好意思
作者:
chenyx
时间:
2011-04-19 16:40
eth0的包不是转给BASE处理了吗
作者:
jamesbert
时间:
2011-04-19 16:43
这个周末就上这部分的课程。
作者:
xyq003478
时间:
2011-04-20 11:56
我的理解是自定义相当于动作。
iptables -N BASE
iptables -t filter -A FORWARD -i eth0 -s 0/0 -p all -m state --state NEW,ESTABLISHED,RELATED -j BASE(1)
iptables -t filter -A BASE -m hashlimit --hashlimit-name spe_base --hashlimit-mode srcip --hashlimit 100/sec -j ACCEPT(2)
iptables -t filter -A BASE -j DROP(3)
用1的条件去执行2和3
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2