#!/bin/sh # USAGE: # ./$0|/bin/sh # This program just writes out the script INTERN_DEV=eth0 echo tc qdisc del dev ${INTERN_DEV} root DEVCEIL=10000kbps VLAN3INCEIL=500kbps VLAN3OUTCEIL=90kbps VLAN4INCEIL=1000kbps VLAN4OUTCEIL=90kbps VLAN5OUTCEIL=2500kbps REMAINDER=100kbps VOIPSERVER=192.168.0.18 TC="tc qdisc add dev eth0" TP="tc class add dev eth0 parent" TF="tc filter add dev eth0 parent 1:0 protocol ip" dotq() { echo tc qdisc add dev ${theDevice} "$@" } dotc() { echo tc class add dev ${theDevice} parent ${theParent} classid "$@" } dotf() { echo tc filter add dev ${theDevice} parent ${theParent} protocol ${theProtocol} "$@" } domark() { INTERFACE="--out-interface $2" ROUTING=POSTROUTING if [ "$1" = "in" ] ; then ROUTING=PREROUTING INTERFACE="--in-interface $2" fi MARK=${3} shift;shift;shift echo iptables -t mangle --append ${ROUTING} ${INTERFACE} "$@" --jump MARK --set-mark ${MARK} } ( theProtocol=ip theDevice=eth0 dotq root handle 1: htb default 11 theParent=1: dotc 1:1 htb rate ${DEVCEIL} ceil ${DEVCEIL} theParent=1:1 dotc 1:11 htb rate ${REMAINDER} ceil ${DEVCEIL} dotc 1:12 htb rate ${REMAINDER} ceil ${DEVCEIL} # OUTGOING ADSL #1 dotc 1:130 htb rate ${VLAN3OUTCEIL} ceil ${VLAN3OUTCEIL} ; ( theParent=1:0 dotf handle 3001 fw flowid 1:130 dotf handle 3002 fw flowid 1:130 dotf handle 3003 fw flowid 1:130 dotq parent 1:130 handle 1300 prio bands 3 priomap 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ; ( theParent=1300: dotq parent ${theParent}1 pfifo dotq parent ${theParent}2 pfifo dotq parent ${theParent}3 pfifo dotf handle 3001 fw flowid 1300:1 dotf handle 3002 fw flowid 1300:2 dotf handle 3003 fw flowid 1300:3 ) domark out vlan3 3003 domark out vlan3 3002 --match length --length 0:400 domark out vlan3 3001 --source ${VOIPSERVER} ) dotc 1:131 htb rate ${VLAN3INCEIL} ceil ${VLAN3INCEIL} ; ( theParent=1:0 dotf handle 3101 fw flowid 1:131 dotf handle 3102 fw flowid 1:131 dotf handle 3103 fw flowid 1:131 dotq parent 1:131 handle 1310 prio bands 3 priomap 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ; ( theParent=1310: dotq parent ${theParent}1 pfifo dotq parent ${theParent}2 pfifo dotq parent ${theParent}3 pfifo dotf handle 3101 fw flowid 1310:1 dotf handle 3102 fw flowid 1310:2 dotf handle 3103 fw flowid 1310:3 ) domark in vlan3 3103 domark in vlan3 3102 --match length --length 0:400 domark in vlan3 3101 --proto udp --destination-port 4569 ) dotc 1:140 htb rate ${VLAN4OUTCEIL} ceil ${VLAN4OUTCEIL} ; ( theParent=1:0 dotf handle 4001 fw flowid 1:140 dotf handle 4002 fw flowid 1:140 dotf handle 4004 fw flowid 1:140 dotq parent 1:140 handle 1400 prio bands 3 priomap 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ; ( theParent=1400: dotq parent ${theParent}1 pfifo dotq parent ${theParent}2 pfifo dotq parent ${theParent}3 pfifo dotf handle 4001 fw flowid 1400:1 dotf handle 4002 fw flowid 1400:2 dotf handle 4003 fw flowid 1400:3 ) domark out vlan4 4003 domark out vlan4 4002 --match length --length 0:400 domark out vlan4 4001 --source ${VOIPSERVER} ) dotc 1:141 htb rate ${VLAN4INCEIL} ceil ${VLAN4INCEIL} ; ( theParent=1:0 dotf handle 4101 fw flowid 1:141 dotf handle 4102 fw flowid 1:141 dotf handle 4103 fw flowid 1:141 dotq parent 1:141 handle 1410 prio bands 3 priomap 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ; ( theParent=1410: dotq parent ${theParent}1 pfifo dotq parent ${theParent}2 pfifo dotq parent ${theParent}3 pfifo dotf handle 4101 fw flowid 1410:1 dotf handle 4102 fw flowid 1410:2 dotf handle 4103 fw flowid 1410:3 ) domark in vlan3 4103 domark in vlan3 4102 --match length --length 0:400 domark in vlan3 4101 --proto udp --destination-port 4569 ) dotc 1:15 htb rate ${VLAN5OUTCEIL} ceil ${VLAN5OUTCEIL} ) exit 0 -ethernet MAX 100Mbit -- vlan1 office rest -- vlan2 oob-management rest -- vlan3 cistron adsl MAX 900kbit up 5000kbit down -- vlan4 tweak B16 adsl MAX 900kbit up 11000kbit down -- vlan5 wifi Send/Receive 2500megabit? vlan3 OUT 90kbps vlan4 OUT 90kbps vlan3 IN 500kbps vlan4 IN 1000kbps