|
HTB skrypy
c4meleon - 22-11-2007 01:17
Witam, od dluzszego czasu chce podzielic lacze (netia 1Mbit) na dwa komputery, mam server do ktorego sa one podlaczone, chce podzilic lacze na sztywno aby oba komputery mialy po polowie lacza czyli po ok 500Kbit, przeczytalem wiele poradniokow, tutoriali na temat htb i nie moge tego pojac, czy znacie jakies gotowe skrypty do mojej konfiguracji ?? z gory bardzo dziekuje, pozdrawiam
tomii - 22-11-2007 08:30
#!/bin/sh # shaper.sh -- prosty i Ă…‚atwy skrypt do zarzĂ„…dzania pasmem if [ "$1" == "stop" ] then echo "Zatrzymujemy shapera" tc qdisc del root dev eth2 2>/dev/null tc qdisc del root dev eth0 2>/dev/null iptables -t mangle -D POSTROUTING -o eth0 -j MYSHAPER-OUT 2>/dev/null iptables -t mangle -F MYSHAPER-OUT 2>/dev/null iptables -t mangle -X MYSHAPER-OUT 2>/dev/null exit fi if [ "$1" == "start" ] then # To co byĂ…‚o wczeĂ…›niej -- do pieca! :) echo "Uruchamiamy shapera" tc qdisc del root dev eth2 2>/dev/null tc qdisc del root dev eth0 2>/dev/null iptables -t mangle -D POSTROUTING -o eth0 -j MYSHAPER-OUT 2>/dev/null iptables -t mangle -F MYSHAPER-OUT 2>/dev/null iptables -t mangle -X MYSHAPER-OUT 2>/dev/null ########## DOWNLOAD tc qdisc add dev eth2 root handle 1:0 htb tc class add dev eth2 parent 1:0 classid 1:1 htb rate 90000kbit ceil 90000kbit tc class add dev eth2 parent 1:1 classid 1:2 htb rate 1400kbit ceil 1400kbit tc class add dev eth2 parent 1:1 classid 1:3 htb rate 85000kbit ceil 85000kbit tc class add dev eth2 parent 1:2 classid 1:4 htb rate 300kbit ceil 1400kbit tc class add dev eth2 parent 1:2 classid 1:5 htb rate 300kbit ceil 1400kbit tc class add dev eth2 parent 1:2 classid 1:6 htb rate 300kbit ceil 1400kbit tc class add dev eth2 parent 1:2 classid 1:7 htb rate 300kbit ceil 1400kbit tc filter add dev eth2 protocol ip preference 1 parent 1:0 u32 match ip \ src 192.168.1.1 flowid 1:3 tc filter add dev eth2 protocol ip preference 1 parent 1:0 u32 match ip \ dst 192.168.1.2 flowid 1:4 tc filter add dev eth2 protocol ip preference 1 parent 1:0 u32 match ip \ dst 192.168.1.3 flowid 1:5 tc filter add dev eth2 protocol ip preference 1 parent 1:0 u32 match ip \ dst 192.168.1.4 flowid 1:6 tc filter add dev eth2 protocol ip preference 1 parent 1:0 u32 match ip \ dst 192.168.1.5 flowid 1:7 tc qdisc add dev eth2 parent 1:3 handle 3:0 sfq perturb 10 tc qdisc add dev eth2 parent 1:4 handle 4:0 sfq perturb 10 tc qdisc add dev eth2 parent 1:5 handle 5:0 sfq perturb 10 tc qdisc add dev eth2 parent 1:6 handle 6:0 sfq perturb 10 tc qdisc add dev eth2 parent 1:7 handle 7:0 sfq perturb 10 ########## UPLOAD tc qdisc add dev eth0 root handle 1:0 htb tc class add dev eth0 parent 1:0 classid 1:1 htb rate 192kbit ceil 192kbit #quantum 15 #tc class add dev eth0 parent 1:1 classid 1:2 htb rate 48kbit ceil 48kbit #quantum 16 tc class add dev eth0 parent 1:1 classid 1:9 htb rate 32kbit ceil 32kbit #quantum 15
tc class add dev eth0 parent 1:1 classid 1:3 htb rate 40kbit ceil 40kbit #quantum 16 tc class add dev eth0 parent 1:1 classid 1:4 htb rate 40kbit ceil 40kbit #quantum 16 tc class add dev eth0 parent 1:1 classid 1:5 htb rate 40kbit ceil 40kbit #quantum 16 tc class add dev eth0 parent 1:1 classid 1:6 htb rate 40kbit ceil 40kbit #quantum 16 # tc qdisc add dev eth0 parent 1:2 handle 2:0 sfq perturb 10 tc qdisc add dev eth0 parent 1:3 handle 3:0 sfq perturb 10 tc qdisc add dev eth0 parent 1:4 handle 4:0 sfq perturb 10 tc qdisc add dev eth0 parent 1:5 handle 5:0 sfq perturb 10 tc qdisc add dev eth0 parent 1:6 handle 6:0 sfq perturb 10
tc qdisc add dev eth0 parent 1:9 handle 9:0 sfq perturb 10
#tc filter add dev eth0 protocol ip preference 1 parent 1:0 handle 20 fw flowid 1:2 # tc filter add dev eth0 parent 1:0 protocol ip handle 1 fw flowid 1:9 tc filter add dev eth0 protocol ip preference 1 parent 1:0 handle 1 fw flowid 1:9 tc filter add dev eth0 protocol ip preference 1 parent 1:0 handle 21 fw flowid 1:3 tc filter add dev eth0 protocol ip preference 1 parent 1:0 handle 22 fw flowid 1:4 tc filter add dev eth0 protocol ip preference 1 parent 1:0 handle 23 fw flowid 1:5 tc filter add dev eth0 protocol ip preference 1 parent 1:0 handle 24 fw flowid 1:6
iptables -t mangle -A OUTPUT -o eth0 -j MARK --set-mark 1 iptables -t mangle -N MYSHAPER-OUT iptables -t mangle -I POSTROUTING -o eth0 -j MYSHAPER-OUT iptables -t mangle -A MYSHAPER-OUT -p tcp -s 192.168.1.2 -j MARK --set-mark 21 iptables -t mangle -A MYSHAPER-OUT -p tcp -s 192.168.1.3 -j MARK --set-mark 22 iptables -t mangle -A MYSHAPER-OUT -p tcp -s 192.168.1.4 -j MARK --set-mark 23 iptables -t mangle -A MYSHAPER-OUT -p tcp -s 192.168.1.5 -j MARK --set-mark 24 iptables -t mangle -A MYSHAPER-OUT -m mark --mark 0 -j MARK --set-mark 20 exit fi if [ "$1" == "status" ] then echo "eth2: " tc -s qdisc show dev eth2 echo "eth0: " tc -s qdisc show dev eth0 exit fi echo "$0 start|stop|status" ## KONIEC
czego nie urzywasz zaplotkuj i ustaw swoje predkosci jest w nim male niedociagniecie ale nad tym pracuje
zanotowane.pldoc.pisz.plpdf.pisz.plminister.pev.pl
|