Hi ! I have an error in this script as it is not working and I can''t figure out what that is. Anyone can help? Thanks! #!/bin/bash ### unitati de masura pt debit # kbps - kilobytes per second # mbps - megabytes per second # kbit - kilbits per second # mbit - megabits per second EXT_IF="eth0" INT_IF="eth1" TC=/sbin/tc IPTABLES=/sbin/iptables # RATE DOWNLOAD RAD_INET_ALL="1736kbit" RAD_INET_LOW="64kbit" RAD_INET_HIGH="256kbit" RAD_METRO_ALL="90mbit" RAD_METRO_LOW="70mbit" RAD_METRO_HIGH="80mbit" # RATE UPLOAD RUP_INET_ALL="1536kbit" RUP_INET="128kbit" RUP_METRO_ALL="90mbit" RUP_METRO="70mbit" # RATA INTRANET RATE_INTRA="80mbit" DEST="85.120.48.128/25 192.171.172.0/24 10.10.10.0/24 217.156.110.86/32 193.226.18.0/24" if [ "$1" = "status" ] then clear echo "* [ discipline interfata $EXT_IF ]" $TC qdisc show dev $EXT_IF echo "* [ disciplinele interfata $INT_IF ]" $TC qdisc show dev $INT_IF echo "* [ clase interfata $EXT_IF ]" $TC class show dev $EXT_IF echo "* [ clase interfata $INT_IF ]" $TC class show dev $INT_IF echo "* [ filtre interfata $EXT_IF ]" $TC filter show dev $EXT_IF $TC filter show dev $EXT_IF parent 1:20 $TC filter show dev $EXT_IF parent 1:30 echo "* [ filtre interfata $INT_IF ]" $TC filter show dev $INT_IF $TC filter show dev $INT_IF parent 1:20 $TC filter show dev $INT_IF parent 1:30 echo echo "* [ marcarea traficului ]" $IPTABLES -n -t mangle -L POSTROUTING exit fi $TC qdisc delete dev $EXT_IF root 2> /dev/null $TC qdisc delete dev $INT_IF root 2> /dev/null $TC qdisc delete dev $INT_IF ingress 2> /dev/null $IPTABLES -t mangle -F POSTROUTING if [ "$1" = "stop" ] then echo "[*] Managementul debitului este oprit." exit fi ### //// 1] Clasele pentru traficul metropolitan/internet pt ambele interfeĆ¾e: $TC qdisc add dev $EXT_IF root handle 1: htb default 30 $TC class add dev $EXT_IF parent 1: classid 1:1 htb rate 100mbit $TC class add dev $EXT_IF parent 1:1 classid 1:20 htb rate $RUP_METRO_ALL $TC class add dev $EXT_IF parent 1:1 classid 1:30 htb rate $RUP_INET_ALL $TC qdisc add dev $INT_IF root handle 1: htb default 30 $TC class add dev $INT_IF parent 1: classid 1:1 htb rate 100mbit $TC class add dev $INT_IF parent 1:1 classid 1:20 htb rate $RAD_METRO_ALL $TC class add dev $INT_IF parent 1:1 classid 1:30 htb rate $RAD_INET_ALL ### //// 2] Clasificarea explicita a traficului metropolitan for i in $DEST; do $TC filter add dev $EXT_IF parent 1: protocol ip u32 match ip dst $i flowid 1:20 $TC filter add dev $INT_IF parent 1: protocol ip u32 match ip src $i flowid 1:20 done ### /// 3] Clasele pentru fiecare client # # client adresa marcaj metro internet # ------------------------------------------------------------------ # client 1 85.120.48.0/25 1 :21 :31 # client 2 192.168.2.0/24 2 :22 :32 # client 3 192.168.3.0/24 3 :23 :33 # client 4 192.168.4.0/24 4 :24 :34 ### Client 1 => #85.120.48.0/25 # clase $TC class add dev $EXT_IF parent 1:20 classid 1:21 htb rate $RUP_METRO $TC class add dev $EXT_IF parent 1:30 classid 1:31 htb rate $RUP_INET $TC class add dev $INT_IF parent 1:20 classid 1:21 htb rate $RAD_METRO_LOW ceil $RAD_METRO_HIGH $TC class add dev $INT_IF parent 1:30 classid 1:31 htb rate $RAD_INET_LOW ceil $RAD_INET_HIGH # marcare $IPTABLES -t mangle -A POSTROUTING -o $EXT_IF -s 85.120.48.0/25 -j MARK --set-mark 1 $IPTABLES -t mangle -A POSTROUTING -o $INT_IF -d 85.120.48.0/25 -j MARK --set-mark 1 # clasificare $TC filter add dev $EXT_IF parent 1:20 protocol ip handle 1 fw flowid 1:21 $TC filter add dev $EXT_IF parent 1:30 protocol ip handle 1 fw flowid 1:31 $TC filter add dev $INT_IF parent 1:20 protocol ip handle 1 fw flowid 1:21 $TC filter add dev $INT_IF parent 1:30 protocol ip handle 1 fw flowid 1:31 ### //// 4] Limitare traficului intre retelele din intranet #$TC qdisc add dev $INT_IF ingress handle ffff: #$TC filter add dev $INT_IF parent ffff: protocol ip u32 match ip dst 85.120.48.0/24 police rate $RATE_INTRA burst 10k drop flowid :1 echo "[*] Managementul debitului este activ." --------------------------------- Yahoo! for Good Click here to donate to the Hurricane Katrina relief effort. _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
On Wednesday 28 September 2005 03:14, Daniel Phlander wrote:> I have an error in this script as it is not working and I can''t figure > out what that is.Your current class trees look like this: eth0 HTB root qdisc 1: (default 30) | \--- HTB root class 1:1 (100mbit) | \--- HTB parent class 1:20 (90mbit) | | | \--- HTB leaf class 1:21 (70mbit) \--- HTB parent class 1:30 (1536kbit) | \--- HTB leaf class 1:31 (128kbit) eth1 HTB root qdisc 1: (default 30) | \--- HTB root class 1:1 (100mbit) | \--- HTB parent class 1:20 (90mbit) | | | \--- HTB leaf class 1:21 (70mbit | 80mbit) \--- HTB parent class 1:30 (1736kbit) | \--- HTB leaf class 1:31 (64kbit | 256kbit)> ### /// 3] Clasele pentru fiecare client > # > # client adresa marcaj metro internet > # ------------------------------------------------------------------ > # client 1 85.120.48.0/25 1 :21 :31 > # client 2 192.168.2.0/24 2 :22 :32 > # client 3 192.168.3.0/24 3 :23 :33 > # client 4 192.168.4.0/24 4 :24 :34I don''t understand the language of the comments, so I ignored them earlier. But I take it that the 1:21 and 1:31 classes are supposed to be user classes and there will be more following? If done right, that would make sense. You have to make sure that child class rates add up to the parent class rate. So for example, since you gave 1:21 70mbit of 90mbit, the other clients together are not allowed to take more than 20mbit of guaranteed rate. The only problem left fixing then are the filters. Your default class in both cases is 30, that''s no good because it''s no leaf, but a parent class. Then you have filters pointing to parent classes and filters attached to parent classes. That''s probably no good either; so far I only had success when attaching filters directly to the QDisc. So all your filter rules must look something like this: tc filter add dev <device> parent 1: bla bla bla flowid 1:x where x has to be a leaf class (currently 21 or 31 only). Same goes for default value, it must be a leaf class. HTH Andreas