htb - porazka

pbern@pbern.biz pbern w pbern.biz
Sob, 5 Cze 2004, 16:19:53 CEST


Gdyby ktos moglby mi pomoc.. bo juz nie mam pomyslow...
kernel-2.6.5-1 + otoczenie

generator + plik z ipkami w zalaczniku...
na maszynce jest dnat/snat....

Pozdrawiam
Pawel Bernadowski
GG 3377, email kontakt w pbern.biz
-------------- następna część ---------
640 32 192.168.0.11 
640 32 192.168.0.12 192.168.0.14 192.168.0.15 
640 32 192.168.0.18 
640 32 192.168.0.19 
640 32 192.168.0.10 192.168.0.13 
-------------- następna część ---------
#!/bin/sh
#Okreslenie KLAS - definicja wyjscia itp

SRV="192.168.0.1"
SUBNET="192.168.0.0/24"
OUT_FILE="./wynik"
TC=tc
IPTABLES=iptables

echo -n > $OUT_FILE

# ETH 0 - LAN
echo "tc qdisc del root dev eth0" >> $OUT_FILE
echo "tc qdisc add dev eth0 root handle 1:0 htb" >> $OUT_FILE
echo "tc class add dev eth0 parent 1:0 classid 1:1 htb rate 10mbit ceil 10mbit" >> $OUT_FILE

echo "tc class add dev eth0 parent 1:1 classid 1:2 htb rate 4mbit ceil 4mbit" >> $OUT_FILE
echo "tc class add dev eth0 parent 1:1 classid 1:3 htb rate 4mbit ceil 4mbit" >> $OUT_FILE
echo "tc class add dev eth0 parent 1:1 classid 1:4 htb rate 1kbit ceil 1kbit" >> $OUT_FILE

echo "tc filter add dev eth0 protocol ip preference 1 parent 1:0 handle 2 fw flowid 1:2" >> $OUT_FILE

echo "tc filter add dev eth0 protocol ip preference 10 parent 1:0 handle 4 fw flowid 1:4" >> $OUT_FILE

# ETH1 - WAN
echo "tc qdisc del root dev eth1" >> $OUT_FILE
echo "tc qdisc add dev eth1 root handle 1:0 htb" >> $OUT_FILE
echo "tc class add dev eth1 parent 1:0 classid 1:1 htb rate 128kbit ceil 128kbit" >> $OUT_FILE

echo "tc class add dev eth1 parent 1:1 classid 1:2 htb rate 128kbit ceil 128kbit" >> $OUT_FILE
echo "tc class add dev eth1 parent 1:1 classid 1:3 htb rate 128kbit ceil 128kbit" >> $OUT_FILE
echo "tc class add dev eth1 parent 1:1 classid 1:4 htb rate 1kbit ceil 1kbit" >> $OUT_FILE

echo "tc filter add dev eth1 protocol ip preference 1 parent 1:0 u32 match ip src $SRV flowid 1:2" >> $OUT_FILE
echo "tc filter add dev eth1 protocol ip preference 1 parent 1:0 u32 match ip src $SUBNET flowid 1:2" >> $OUT_FILE
echo "tc filter add dev eth1 protocol ip preference 10 parent 1:0 u32 match ip dst $SUBNET flowid 1:4" >> $OUT_FILE

#### Preparowanie iptables
echo "$IPTABLES -t mangle -F PREROUTING" >> $OUT_FILE

n=6 # Class ID
while read qos; do
downstream=`echo $qos | cut -d' ' -f 1`
upstream=`echo $qos | cut -d' ' -f 2`
iplist=`echo $qos | cut -d' ' -f 3-`

down_min=$(($downstream * 1/16))
down_max=$downstream

up_min=$(($upstream *  1/16))
up_max=$upstream

echo "$TC class add dev eth0 parent 1:3 classid 1:$n htb rate $down_min\kbit ceil $down_max\kbit" >> $OUT_FILE
echo "$TC qdisc add dev eth0 parent 1:$n handle $n: sfq perturb 10" >> $OUT_FILE
echo "$TC class add dev eth1 parent 1:3 classid 1:$n htb rate $up_min\kbit ceil $up_max\kbit" >> $OUT_FILE
echo "$TC qdisc add dev eth1 parent 1:$n handle $n: sfq perturb 10" >> $OUT_FILE

for i in `echo $iplist`; do
echo "$TC filter add dev eth0 protocol ip parent 1: u32 match ip dst $i flowid 1:$n" >> $OUT_FILE
echo "$TC filter add dev eth1 protocol ip parent 1: u32 match ip src $i flowid 1:$n" >> $OUT_FILE
echo "$IPTABLES -t mangle -A PREROUTING -s $i -j MARK --set-mark $n" >> $OUT_FILE

done

n=$(($n + 1))
done


Więcej informacji o liście dyskusyjnej pld-users-pl