系统平台 RedHat AS4
[root@bridgenet software]# uname -a
Linux bridgenet 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686 i686 i386 GNU/Linux
[root@bridgenet software]# rpm -ivh bridge-utils-1.0.4-4.i386.rpm
[root@bridgenet software]# rpm -ivh iproute-2.6.9-3.i386.rpm
网桥启动脚本
#!/bin/sh
/usr/sbin/brctl addbr br0
/usr/sbin/brctl addif br0 eth0
/usr/sbin/brctl addif br0 eth1
/sbin/ifconfig eth0 0.0.0.0  promisc
/sbin/ifconfig eth1 0.0.0.0  promisc
/sbin/ifconfig br0 up
TC流量控制脚本
#!/bin/bash
modprobe ip_tables
modprobe ip_nat_ftp
modprobe ip_conntrack
modprobe ip_conntrack_ftp
iptables -F -t nat
iptables -F
#iptables -A INPUT  -j ACCEPT
#iptables -A OUTPUT  -j  ACCEPT
#iptables -A FORWARD -j ACCEPT
#iptables -F -t mangle
#iptables -X -t mangle
#iptables -Z -t mangle
#echo "1" >; /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
## DEV_INTERNET NETWORK DEV_INTERFACE
DEV_IN="eth0"
## DEV_INNER NETWORK DEV_INTERFACE
DEV_OUT="eth1"
#tc qdisc del dev $DEV_OUT root
#tc qdisc del dev $DEV_IN  root
tc qdisc del dev ${DEV_OUT} root    2> /dev/null > /dev/null
tc qdisc del dev ${DEV_OUT} ingress 2> /dev/null > /dev/null
tc qdisc del dev ${DEV_IN} root    2> /dev/null > /dev/null
tc qdisc add dev $DEV_OUT root handle 1:0 htb default 10
tc class add dev $DEV_OUT parent 1:0 classid 1:1 htb rate 100Mbps burst 15k
i=2
while [ $i -lt 255 ]
do
tc class add dev $DEV_OUT parent 1:1 classid 1:1$i  htb rate  800kbit ceil 800kbit  burst 15k
i=`expr $i + 1`
done
i=2
while [ $i -lt 255 ]
do
tc qdisc add dev $DEV_OUT parent 1:1$i  handle 1$i: sfq perturb 10
i=`expr $i + 1`
done
U32_ONE="tc filter add dev $DEV_OUT protocol ip parent 1:0 prio 1 u32"
i=2
while [ $i -lt  255 ]
do
$U32_ONE  match ip src 10.10.100.$i  flowid 1:1$i
$U32_ONE  match ip src 10.10.101.$i  flowid 1:1$i
i=`expr $i + 1`
done

#IN
tc qdisc add dev $DEV_IN  root handle 2:0 htb default 10
tc class add dev $DEV_IN  parent 2:0 classid 2:1 htb rate 100Mbps burst 15k
j=2
while [ $j  -lt  255 ]
do
tc class add dev $DEV_IN  parent 2:1 classid 2:1$j  htb rate 800kbit  ceil 800kbit  burst 15k
j=`expr $j + 1`
done
j=2
while [ $j  -lt  255 ]
do
tc qdisc add dev $DEV_IN  parent 2:1$j  handle 1$j: sfq perturb 10
j=`expr $j + 1`
done
U32_THREE="tc filter add dev $DEV_IN  protocol ip parent 2:0 prio 1 u32"
j=2
while [ $j  -lt  255 ]
do
$U32_THREE   match ip dst  10.10.100.$j  flowid 2:1$j
$U32_THREE   match ip dst  10.10.101.$j  flowid 2:1$j
j=`expr $j + 1`
done