DOWNLOAD=800Kbit
UPLOAD=160Kbit
INET=1921680
IPS=1
IPE=253
ServerIP=254
IDEV=eth0
ODEV=ppp0
/sbin/tc qdisc del dev $IDEV root handle 10:
/sbin/tc qdisc del dev $ODEV root handle 20:
/sbin/tc qdisc add dev $IDEV root handle 10: cbq bandwidth 100Mbit avpkt 1000
/sbin/tc qdisc add dev $ODEV root handle 20: cbq bandwidth 1Mbit avpkt 1000
/sbin/tc class add dev $IDEV parent 10:0 classid 10:1 cbq bandwidth 100Mbit rate 100Mbit allot 1514 weight 1Mbit prio 8 maxburst 20 avpkt 1000
/sbin/tc class add dev $ODEV parent 20:0 classid 20:1 cbq bandwidth 1Mbit rate 1Mbit allot 1514 weight 10Kbit prio 8 maxburst 20 avpkt 1000
/sbin/tc class add dev $IDEV parent 10:1 classid 10:10 cbq bandwidth 100Mbit rate 95Mbit allot 1514 weight 20Kbit prio 5 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev $IDEV parent 10:10 sfq quantum 1514b perturb 15
/sbin/tc filter add dev $IDEV parent 10:0 protocol ip prio 50 u32 match ip src $INET$ServerIP flowid 10:10
COUNTER=$IPS
while [ $COUNTER -le $IPE ]
do
/sbin/tc class add dev $IDEV parent 10:1 classid 10:1$COUNTER cbq bandwidth 100Mbit rate $DOWNLOAD allot 1514 weight 20Kbit prio 5 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev $IDEV parent 10:1$COUNTER sfq quantum 1514b perturb 15
/sbin/tc filter add dev $IDEV parent 10:0 protocol ip prio 100 u32 match ip dst $INET$COUNTER flowid 10:1$COUNTER
COUNTER=` expr $COUNTER + 1 `
done
COUNTER=$IPS
while [ $COUNTER -le $IPE ]
do
/sbin/tc class add dev $ODEV parent 20:1 classid 20:1$COUNTER cbq bandwidth 1Mbit rate $UPLOAD allot 1514 weight 4Kbit prio 5 maxburst 20 avpkt 1000 bounded
/sbin/tc qdisc add dev $ODEV parent 20:1$COUNTER sfq quantum 1514b perturb 15
/sbin/tc filter add dev $ODEV parent 20:0 protocol ip prio 100 handle $COUNTER fw classid 20:1$COUNTER
COUNTER=` expr $COUNTER + 1 `
done
NIP=78
ND=200Kbit
NU=50Kbit
/sbin/tc class change dev $IDEV parent 10:1 classid 10:1$NIP bandwidth 100Mbit rate $ND allot 1514 weight 20Kbit prio 5 maxburst 20 avpkt 1000 bounded
/sbin/tc class change dev $ODEV parent 20:1 classid 20:1$NIP cbq bandwidth 1Mbit rate $NU allot 1514 weight 4Kbit prio 5 maxburst 20 avpkt 1000 bounded
NIP=1
ND=1500Kbit
NU=500Kbit
/sbin/tc class change dev $IDEV parent 10:1 classid 10:1$NIP bandwidth 100Mbit rate $ND allot 1514 weight 20Kbit prio 5 maxburst 20 avpkt 1000 bounded
/sbin/tc class change dev $ODEV parent 20:1 classid 20:1$NIP cbq bandwidth 1Mbit rate $NU allot 1514 weight 4Kbit prio 5 maxburst 20 avpkt 1000 bounded
COUNTER=$IPS
while [ $COUNTER -lt $IPE ]
do
iptables -t mangle -A PREROUTING -i $IDEV -s $INET$COUNTER -j MARK --set-mark $COUNTER
COUNTER=` expr $COUNTER + 1 `
done
iptables -t nat -A POSTROUTING -o $EXTIF -s 19216800/24 -j MASQUERADE
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)