续。。。


#!/bin/sh
#
# Script by Ron Senykoff 2005
#####################################
############ VARIABLES ##############
# #
e=eth0 # interface
nonVoipRate=150kbps # throttle for nonVoip - make sure to keep is slow enough
citrix=60kbps
video=110kbps
sametime=5kbps
bulk=10kbps

COLO1="x.x.x.x" # substitute IPs here
COLO2="x.x.x.x"
SAMETIME="x.x.x.x"
# #
#####################################
#####################################

# Delete any old rules #
tc qdisc del root dev $e

#ifconfig $e txqueuelen 10
# root qdisc / qdisc = queueing discipline #
tc qdisc add dev $e root handle 1: prio bands 2 priomap 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
# creates classes 1:1 and 1:2

# put a pfifo on so we can see it at the console
tc qdisc add dev $e parent 1:1 handle 11: pfifo

# on the second band of the prio we but an htb to keep
# the rest of the traffic from ever overrunning the link
# any traffic not caught by our filters goes to the bulk category
tc qdisc add dev $e parent 1:2 handle 10: htb default 40
tc class add dev $e parent 10: classid 10:1 htb rate $nonVoipRate

# define the inner classes of the htb - prioritized from 10 - 40
tc class add dev $e parent 10:1 classid 10:10 htb rate $citrix ceil $nonVoipRate quantum 1500
tc class add dev $e parent 10:1 classid 10:20 htb rate $video ceil $nonVoipRate
tc class add dev $e parent 10:1 classid 10:30 htb rate $sametime ceil $nonVoipRate quantum 1500
tc class add dev $e parent 10:1 classid 10:40 htb rate $bulk ceil $nonVoipRate quantum 1500

# add queues onto the htb classes
# default is pfifo - but this lets us see it with tc -s qdisc show dev eth0
tc qdisc add dev $e parent 10:10 handle 100: pfifo limit 50
tc qdisc add dev $e parent 10:20 handle 200: pfifo limit 10
tc qdisc add dev $e parent 10:30 handle 300: pfifo limit 10
# fair queuing on the bulk traffic
tc qdisc add dev $e parent 10:40 handle 400: sfq perturb 10

#####################################
############### VoIP ################
# #

# IAX # this is the old format - IAX2 should be what's really seen going on
tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip sport 5036 0xffff flowid 1:1
tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip dport 5036 0xffff flowid 1:1

# IAX2 #
tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip sport 4569 0xffff flowid 1:1
tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip dport 4569 0xffff flowid 1:1

# match icmp echo request
#tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip icmp_type 0x08 0xff flowid 1:1

# match icmp echo reply
#tc filter add dev $e protocol ip parent 1: prio 1 u32 match ip icmp_type 0x00 0xff flowid 1:1

######################################
# forward the rest to second priority#
tc filter add dev $e protocol ip parent 1: prio 2 u32 match ip src 0.0.0.0/0 flowid 1:2
tc filter add dev $e protocol ip parent 1: prio 2 u32 match ip dst 0.0.0.0/0 flowid 1:2


#####################################################
#### Classify band 2 of the priority queue ##########
#####################################################
## ##
## ##


#####################################
############### Citrix ##############
# #

# SSH #
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 22 0xffff flowid 10:10
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 22 0xffff flowid 10:10

# CITRIX/ICA #
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip sport 1494 0xffff flowid 10:10
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dport 1494 0xffff flowid 10:10

# CITRIX Metaframe #
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip src $CONNECTRIA1/32 flowid 10:10
tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip dst $CONNECTRIA1/32 flowid 10:10

tc filter add dev $e protocol ip parent 10: prio 1 u32 match ip src $CONNECTRIA2/32 flowid 10:10

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!