- 论坛徽章:
- 0
|
环境:
- [root@router-control ~]# uname -a
- Linux router-control.aaaa.cn 2.6.9-34.EL #1 Fri Feb 24 16:44:51 EST 2006 i686 athlon i386 GNU/Linux
- [root@router-control ~]#
- [root@router-control ~]# cat /etc/redhat-release
- Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
- [root@router-control ~]#
- [root@router-control ~]# iptables -V
- iptables v1.2.11
- [root@router-control ~]# tc -V
- tc utility, iproute2-ss040831
- [root@router-control ~]#
复制代码
3个网卡。
eth0 用于远程管理 192.168.1.253,开ssh。
eth1 和 eth2 做 br0。
- [root@router-control script]# cat mk_br0
- #!/bin/sh
- # create br0
- /usr/sbin/brctl addbr br0
- # add IF to br0
- /usr/sbin/brctl addif br0 eth1
- /usr/sbin/brctl addif br0 eth2
- # Start up the Ethernet interface
- #/sbin/ifconfig eth1 0.0.0.0 up
- #/sbin/ifconfig eth2 0.0.0.0 up
- # start up br0
- /sbin/ifconfig br0 up
- [root@router-control script]#
复制代码
拓扑结构
Internet
|
|
+------------+
| router |
+------------+
|
|
|eth2
+-------------+
| Linux PC |
| TC |
+-------------+
|eth1
|
|
+-----------------+
| switch |
+-----------------+
TC 脚本 for eth2
- tc qdisc del dev eth2 root 2>/dev/null # clear the exist class
- tc qdisc add dev eth2 root handle 10: htb default 2254 # define root
- tc class add dev eth2 parent 10: classid 10:1 htb rate 5120kbps ceil 5120kbps
- i=2
- while [ $i -le 253 ] # a C class network this for 192.168.1.0/24 .
- do
- j=0
- j=`expr $i + 100`
- echo "$j"
- tc class add dev eth2 parent 10:1 classid 10:$j htb rate 50kbps ceil 64kbps prio 1
- echo "pfifo"
- tc filter add dev eth2 parent 10: protocol ip prio 1 u32 match ip dst 172.20.11.$i/32 classid 10:$j
- echo "match"
- i=`expr $i + 1`
- done
复制代码
TC 脚本 for eth1
- tc qdisc del dev eth1 root 2>/dev/null # clear the exist class
- tc qdisc add dev eth1 root handle 10: htb default 2254 # define root
- tc class add dev eth1 parent 10: classid 10:1 htb rate 5120kbps ceil 5120kbps
- i=2
- while [ $i -le 253 ] # a C class network this for 192.168.1.0/24 .
- do
- j=0
- j=`expr $i + 100`
- echo "$j"
- tc class add dev eth1 parent 10:1 classid 10:$j htb rate 50kbps ceil 64kbps prio 1
- echo "pfifo"
- tc filter add dev eth1 parent 10: protocol ip prio 1 u32 match ip dst 172.20.11.$i/32 classid 10:$j
- echo "match"
- i=`expr $i + 1`
- done
复制代码
执行 eth2 的 tc 脚本能实现下载限速,
执行 eth1 的 tc 脚本不能实现上传限速,把 dev 改成 br0 也不能对上传限速,
不知道我的方法是否有误。请大家指教。
还有如果我想实现NAT,由于eth1 和 eth2都没有配IP,不知道能否可以实现?方法如何?
谢谢! |
|