On Tue 21 Sep 2004 at 19:59:14, Soren Harward said:
> WARNING: This e-mail has been altered by MIMEDefang.

Stupid MIMEDefang.  Here's the script again.

-- 
Soren Harward <[EMAIL PROTECTED]> -- http://theboard.byu.edu/
"Americans are always attempting to run away from conformity, but
unfortunately they always start running in the same direction."
                                                  -- Art Buchwald
#!/bin/bash
RESERVE=16
DOWNLINK=$((1536-RESERVE))
UPLINK=$((1024-RESERVE))
DEV=eth3

# reset existing tc rules
tc qdisc del dev $DEV root &> /dev/null
tc qdisc del dev $DEV ingress &> /dev/null

########## uplink #############
# attach root HTB
tc qdisc add dev $DEV root handle 1: htb default 30

# limit everything to the uplink speed
tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit burst 15k

# high priority class
tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit burst 15k

# normal class
tc class add dev $DEV parent 1:1 classid 1:20 htb rate $((UPLINK*3/4))kbit ceil 
$((UPLINK*9/10))kbit burst 15k

# bulk class
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 1kbit ceil $((UPLINK*3/4))kbit 
burst 15k

# all queues get stochastic fairness
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10

######
# Filters for 1:30 (bulk priority)
######

# BitTorrent (tcp ports 6881-6889)
# TODO: add the rest of the ports
tc filter add dev $DEV parent 1:0 protocol ip prio 14 u32 \
   match ip protocol 6 0xff \
   match ip src 192.168.0.0/16 \
   match ip sport 6881 0xffff \
   flowid 1:30

######
# Filters for 1:10 (highest priority)
######

# ToS interactive
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip tos 0x10 0xff 
flowid 1:10

# ICMP
tc filter add dev $DEV parent 1:0 protocol ip prio 11 u32 match ip protocol 1 0xff 
flowid 1:10

# TCP ACK packets
tc filter add dev $DEV parent 1:0 protocol ip prio 12 u32 \
   match ip protocol 6 0xff \
   match u8 0x05 0x0f at 0 \
   match u16 0x0000 0xffc0 at 2 \
   match u8 0x10 0xff at 33 \
   flowid 1:10

# DNS
tc filter add dev $DEV parent 1:0 protocol ip prio 13 u32 \
   match ip protocol 17 0xff \
   match ip dport 53 0xffff \
   flowid 1:10

# Everything else ends up in 1:20
tc filter add dev $DEV parent 1:0 protocol ip prio 255 u32 match ip dst 0.0.0.0/0 
flowid 1:20

########## downlink #############
# attach ingress policer
tc qdisc add dev $DEV handle ffff: ingress

# filter *everything* to it (0.0.0.0/0), drop everything that's coming in too fast
tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src 0.0.0.0/0 
police rate ${DOWNLINK}kbit burst 10k drop flowid :1

Attachment: signature.asc
Description: Digital signature

_______________________________________________
newbies mailing list
[EMAIL PROTECTED]
http://phantom.byu.edu/cgi-bin/mailman/listinfo/newbies

Reply via email to