moj skrypt
Kod: Zaznacz cały
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DEV=eth0
DEV_SPEED=1024000
LAN_SPEED=30000
ULMAX=512
UL1=500
UL2=128
#czystki
tc qdisc del dev $DEV root 2> /dev/null > /dev/null
#kolejka glowna
tc qdisc add dev $DEV root handle 1:0 htb
#klasa glowna - predkosc max karty
tc class add dev $DEV parent 1:0 classid 1:1 htb rate ${DEV_SPEED}kbit quantum 16
#pierwsza podklasa - max predkosc uploadu na laczu
tc class add dev $DEV parent 1:1 classid 1:20 htb rate $[95*$ULMAX/100]kbit
#druga podklasa - polaczenia wychodzace z serwera 9/10 predkosci karty
#tc class add dev $DEV parent 1:1 classid 1:30 htb rate $[5*$DEV_SPEED/10]kbit ceil $[9*$DEV_SPEED/10]kbit
#filtr na dane z serwerka
#tc filter add dev $DEV protocol ip preference 1 parent 1:0 u32 match ip src 10.0.0.1 flowid 1:30 #WPISAC IP BRAMY
#tc qdisc add dev $DEV parent 1:30 handle 30:0 sfq perturb 10
#trzecia podklasa - polaczenia do zewnetrznej sieci LAN
tc class add dev $DEV parent 1:1 classid 1:40 htb rate $[$LAN_SPEED/2]kbit ceil ${LAN_SPEED}kbit
#filtry na dane z laniku
tc filter add dev $DEV protocol ip preference 1 parent 1:0 u32 match ip dst 10.200.0.0/16 flowid 1:40
tc filter add dev $DEV protocol ip preference 1 parent 1:0 u32 match ip dst 192.168.0.0/16 flowid 1:40
tc qdisc add dev $DEV parent 1:40 handle 40:0 sfq perturb 10
#czwarta podklasa - operacje time critical
tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${ULMAX}kbit burst 10k prio 1
#SSH
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip tos 0x10 0xff flowid 1:10
#pingi
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip protocol 1 0xff flowid 1:10
#ACK
tc filter add dev $DEV parent 1: protocol ip prio 10 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
#UDP
tc filter add dev $DEV parent 1: prio 10 u32 match ip protocol 0x11 0xff flowid 1:10
#DNS
tc filter add dev $DEV parent 1: protocol ip prio 2 u32 match ip sport 53 0xffff flowid 1:10
#VNC
tc filter add dev $DEV parent 1: protocol ip prio 2 u32 match ip dport 5900 0xffff flowid 1:10
tc filter add dev $DEV parent 1: protocol ip prio 2 u32 match ip dport 5800 0xffff flowid 1:10
tc qdisc add dev $DEV parent 1:10 handle 10:0 sfq perturb 10
#SZKODNIKI
tc class add dev $DEV parent 1:20 classid 1:202 htb rate $[$UL1/2]kbit burst 6Kb prio 2 ceil ${UL1}kbit quantum 4
tc filter add dev $DEV protocol ip preference 1 parent 1:0 handle 10002 fw classid 1:202
tc qdisc add dev $DEV parent 1:202 handle 202:0 sfq perturb 10
tc class add dev $DEV parent 1:20 classid 1:203 htb rate $[$UL1/2]kbit burst 6Kb prio 2 ceil ${UL1}kbit quantum 4
tc filter add dev $DEV protocol ip preference 1 parent 1:0 handle 10003 fw flowid 1:203
tc qdisc add dev $DEV parent 1:203 handle 203:0 sfq perturb 10
tc class add dev $DEV parent 1:20 classid 1:204 htb rate $[$UL1/2]kbit burst 6Kb prio 2 ceil ${UL1}kbit quantum 4
tc filter add dev $DEV protocol ip preference 1 parent 1:0 handle 10004 fw flowid 1:204
tc qdisc add dev $DEV parent 1:204 handle 204:0 sfq perturb 10
tc class add dev $DEV parent 1:20 classid 1:205 htb rate $[$UL2/2]kbit burst 6Kb prio 2 ceil ${UL2}kbit quantum 4
tc filter add dev $DEV protocol ip preference 1 parent 1:0 handle 10005 fw flowid 1:205
tc qdisc add dev $DEV parent 1:205 handle 205:0 sfq perturb 10
for i in `seq 6 25`; do
wan_classid=$(($i+200))
mark=$((10000 + $i))
tc class add dev $DEV parent 1:20 classid 1:$wan_classid htb rate $[$UL2/2]kbit burst 6Kb prio 2 ceil ${UL2}kbit quantum 4
tc filter add dev $DEV protocol ip preference 1 parent 1:0 handle $mark fw flowid 1:$wan_classid
tc qdisc add dev $DEV parent 1:$wan_classid handle $wan_classid:0 sfq perturb 10
done
echo upload services
#psa
tc class add dev $DEV parent 1:20 classid 1:100 htb rate 128kbit burst 6Kb prio 1 ceil 256kbit quantum 4
tc filter add dev $DEV protocol ip preference 1 parent 1:0 handle 51 fw flowid 1:100
tc qdisc add dev $DEV parent 1:100 handle 100:0 sfq perturb 10
echo $DEV zkolejkowane
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
i nie wiem co jest grane - odpowiednie linijki sa zrobione na zasadzie kopiuj-wklej z strony na ktorej sie wzorowalam
piszac to wzorowalam sie na: http://www.debianusers.pl/articles/54