往事依依,随风而行。淡忘过去的一切,在风中迎接新的希望。
浏览模式: 标准 | 列表 | 无广告2010年09月的文章

闲着无聊写了一下qos脚本

tomato 接7mb的adsl  感觉下bt的时候上网很慢。所以就写了一个qos脚本
自己的3台电脑优先,别人次级。

非dhcp分配ip的地址优先级最低,没drop他们的数据包就不错了。

 

不过发现2个问题 在mangle表mark数据包action之前不能用accept,用了accept直接就脱离表了,导致不mark数据包。

这句 害死我了

iptables -t mangle -A NEW_QOSO -m iprange --src-range 192.168.15.100-192.168.15.200 -p udp -m limit --limit 35/sec -j ACCEPT

看着是accept 其实还是drop系列的 只有超过35包每s 计数器才会+1

我原来写了一句iptables -t mangle -A NEW_QOSO -m iprange --src-range 192.168.1.100-192.168.1.200 -p udp  -j ACCEPT

导致不mark数据包。fuck下 iptables

-m iprange --src-range 不支持反取 就是!

 

drop放在  不限速的ip之后  

默认tcp限速放在默认mark之前。

这样就能够对某些ip不限速。

tc 没研究明白 只把htd 看了一下

tc qdisc add dev imq0 root handle 1: htb

 tc class add dev imq0 parent 1: classid 1:1 htb rate 7500kbit
        TCAU="tc class add dev imq1"
        TFAU="tc filter add dev imq1"
        TQAU="tc qdisc add dev imq1"

 

# 192.168.1.110-192.168.1.122: download limit
        $TCA parent 1:1 classid 1:10 htb rate 2000kbit ceil 99999kbit prio 2
        $TQA parent 1:10 handle 10: $SFQ
        $TFA parent 1:0 prio 2 protocol ip handle 11 fw flowid 1:10


# 192.168.1.110-192.168.1.122: down-fast-post
$TFA parent 1:0 prio 1 protocol ip handle 10 fw flowid 1:10

 

这样就是1个class  队列

class限速

然后按照mark值不同进行排队。

qdisc队列长度 写一个就好了。

感觉tc没cisco的qos好用

# tc filter ls dev imq1
filter parent 1: protocol ip pref 1 fw
filter parent 1: protocol ip pref 1 fw handle 0xa classid 1:10
filter parent 1: protocol ip pref 2 fw
filter parent 1: protocol ip pref 2 fw handle 0xb classid 1:10
filter parent 1: protocol ip pref 3 fw
filter parent 1: protocol ip pref 3 fw handle 0xc classid 1:14
filter parent 1: protocol ip pref 4 fw
filter parent 1: protocol ip pref 4 fw handle 0xd classid 1:11
filter parent 1: protocol ip pref 5 fw
filter parent 1: protocol ip pref 5 fw handle 0xe classid 1:11

 

 

Tags: qos, tc, linux