HTB.init / tc在NAT之后

我有一个Ubuntu 10盒,我试图build立一个带宽整形路由器。

机器有一个WAN接口,eth0和两个LAN接口,eth1和eth2。 如InternetConnectionSharing中所述,使用MASQUERADEconfigurationNAT。

我主要关心的是从LAN接口中形成出站stream量 – 最后,我想最终得到每个LAN接口768Kbps的硬限制(而不是所有接口上汇集的eth0限制)。

我安装了HTB.init ,并对示例进行了细化 ,试图通过将三个文件放入/ etc / sysconfig / htb来设置eth1:

的/ etc / SYSCONFIG / HTB / ETH1

DEFAULT=30 R2Q=100 

/etc/sysconfig/htb/eth1-2.root

 RATE=768Kbps BURST=15k 

/etc/sysconfig/htb/eth1-2:30.dfl

 RATE=768Kbps CEIL=788Kbps BURST=15k LEAF=sfq 

我可以/etc/init.d/htb启动和/etc/init.d/htb统计信息,并看到/似乎/build议它的工作信息…但是当我试图通过广域网接口拉大文件塑造清楚没有生效。

有什么build议么? 我的猜测是,这与NAT链中整形的位置有关,但我真的不知道从哪里开始解决这个问题。

—-更新:

这是我的/etc/init.d/htb列表输出,这似乎是有道理的 – eth1的默认速率是768Kbps?

 ### eth0: queueing disciplines qdisc htb 1: root refcnt 2 r2q 100 default 30 direct_packets_stat 0 qdisc sfq 30: parent 1:30 limit 127p quantum 1514b perturb 10sec ### eth0: traffic classes class htb 1:2 root rate 768000bit ceil 768000bit burst 1599b cburst 1599b class htb 1:30 parent 1:2 leaf 30: prio 0 rate 6144Kbit ceil 6144Kbit burst 15Kb cburst 1598b ### eth0: filtering rules filter parent 1: protocol ip pref 100 u32 filter parent 1: protocol ip pref 100 u32 fh 800: ht divisor 1 filter parent 1: protocol ip pref 100 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:30 match 00000000/00000000 at 12 match 00000000/00000000 at 16 ### eth1: queueing disciplines qdisc htb 1: root refcnt 2 r2q 100 default 30 direct_packets_stat 0 qdisc sfq 30: parent 1:30 limit 127p quantum 1514b perturb 10sec ### eth1: traffic classes class htb 1:2 root rate 768000bit ceil 768000bit burst 1599b cburst 1599b class htb 1:30 parent 1:2 leaf 30: prio 0 rate 6144Kbit ceil 6144Kbit burst 15Kb cburst 1598b 

尝试添加(使用您的IP)eth1-2:30.dfl

 RULE=192.168.0.0/24 

我不得不说,我发现这个速度超过100Mbit是非常困难的。 在我的情况下,我想形成2Gbit / s

最后我修改了一个脚本,我发现这个工作。 这是它适应你的需求。 具体来说,您需要将费率调整为有效。 tc理解mbit。 所以你需要放入类似768kbit的东西或者其他可以正确解释的东西。

 #!/bin/sh # # Incoming traffic control # DEV=eth0 RATE="2000mbit" tc qdisc del dev $DEV root tc qdisc add dev $DEV root handle 1: htb default 10 tc class add dev $DEV parent 1: classid 1:1 htb rate ${RATE} burst 15k tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${RATE} ceil ${RATE} burst 15k tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10 echo;echo "tc configuration for $DEV:" tc qdisc show dev $DEV tc class show dev $DEV # # Outgoing traffic control # DEV=eth2 tc qdisc del dev $DEV root tc qdisc add dev $DEV root handle 1: htb default 10 tc class add dev $DEV parent 1: classid 1:1 htb rate ${RATE} burst 15k tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${RATE} ceil ${RATE} burst 15k tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10 echo;echo "tc configuration for $DEV:" tc qdisc show dev $DEV tc class show dev $DEV