Kombinuję z HTB już jakiś czas ale niestety przegrywam walkę.
Wersja jądra jaką mam to 3.2.0, maszyna również nie powala osiągami PIV 2,8GHz i 1,5GB RAM (do testów wystarczy maksymalnie 3 komputery).
Kolejkowanie robiłem według opisu na stronie: http://stary.dug.net.pl/texty/htb.php i korzystam z gotowca zamieszczonego na dole.
Problemem jest brak limitowania prędkości wysyłania, za każdym razem jest wysyłane z maksymalnym transferem. Co jest tego przyczyną?
Pliki wyglądają następująco po drobnych zmianach:
- Lista z adresami IP:
Kod: Zaznacz cały
# Configuration list for eth1 # ::::::::::::::::::::::::::::::::::::::::::::::::: # | IP | GW | MAX | wys | Opis # ::::::::::::::::::::::::::::::::::::::::::::::::: 192.168.125.101 ; 6000 ; 6000 ; 6000 ; xx1 192.168.125.102 ; 2500 ; 4000 ; 2000 ; xx2 192.168.125.103 ; 1000 ; 1000 ; 512 ; xx3 192.168.125.104 ; 1000 ; 1000 ; 512 ; xx4 192.168.125.105 ; 2000 ; 2000 ; 2000 ; xx5 192.168.125.106 ; 128 ; 256 ; 128 ; xx6 #end file
- Skrypt kolejkowania:
Kod: Zaznacz cały
#!/usr/bin/perl # # Kolejkowanie ver 0.000000000001 beta # create by BiExi # # $debugowanie = 0; $cid = 10; $handl = 50; $zrodlo = 60; open (PLIK_SHIT, "/etc/..../list") or die "open $alert_file: $!\n"; { sleep 1; if (seek(PLIK_SHIT,0,1)) { print "--------------------------------------------- \n"; print " KOLEJKOWANIE ETH1 \n"; print "--------------------------------------------- \n"; # - -- ---[ ruch przychodzacy ]--- -- - system "tc qdisc del dev eth1 root handle 1:0 htb"; system "tc qdisc add dev eth1 root handle 1:0 htb"; system "tc class add dev eth1 parent 1:0 classid 1:1 htb rate 99mbit ceil 100mbit"; system "tc class add dev eth1 parent 1:1 classid 1:2 htb rate 59mbit ceil 60mbit"; system "tc class add dev eth1 parent 1:1 classid 1:3 htb rate 98mbit ceil 98mbit"; system "tc filter add dev eth1 protocol ip preference 1 parent 1:0 u32 match ip src 192.168.125.25 flowid 1:3"; system "tc qdisc add dev eth1 parent 1:3 handle 299:0 sfq perturb 10"; # - -- ---[ ruch wychodzacy ]--- -- - system "tc qdisc del dev eth0 root handle 1:0 htb"; system "tc qdisc add dev eth0 root handle 1:0 htb"; system "tc class add dev eth0 parent 1:0 classid 1:1 htb rate 6000kbit ceil 6000kbit"; system "tc class add dev eth0 parent 1:1 classid 1:2 htb rate 5950kbit ceil 5950kbit"; system "tc qdisc add dev eth0 parent 1:2 handle 2:0 sfq perturb 10"; system "tc filter add dev eth0 protocol ip preference 1 parent 1:0 handle 2000 fw flowid 1:2"; system "iptables -t mangle -N UPIER_ETH0"; system "iptables -t mangle -D POSTROUTING -o eth0 -j UPIER_ETH0"; system "iptables -t mangle -I POSTROUTING -o eth0 -j UPIER_ETH0"; while (<PLIK_SHIT>) { chop; next if (/^\s*$/); # wyjazd z pustymi liniami next if (/^#/); # wyjazd z # if (/(\d+\.\d+\.\d+\.\d+) \; (\d+) \; (\d+) \; (\d+) \; (\S+)/) { print "| Kolejka na eth1 RUCH PRZYCHODZACY dla IP:$1 rate: $2kbit cail: $3kbit \n"; system "tc class add dev eth1 parent 1:2 classid 1:$cid htb rate $2kbit ceil $3kbit burst 50k"; system "tc filter add dev eth1 protocol ip preference 2 parent 1:0 u32 match ip dst $1 flowid 1:$cid"; system "tc qdisc add dev eth1 parent 1:$cid handle $handl:0 sfq perturb 10"; print "| Kolejka na eth1 RUCH WYCHODZACY dla IP:$1 rate: $4kbit cail: $4kbit \n"; system "tc class add dev eth0 parent 1:2 classid 1:$cid htb rate $4bit ceil $4kbit burst 50k"; system "tc qdisc add dev eth0 parent 1:$cid handle $handl:0 sfq perturb 10"; system "tc filter add dev eth0 protocol ip preference 2 parent 1:0 handle $zrodlo fw flowid 1:$cid"; system "iptables -t mangle -D UPIER_ETH0 -p tcp -s $1 -j MARK --set-mark $zrodlo >>/dev/null"; system "iptables -t mangle -A UPIER_ETH0 -p tcp -s $1 -j MARK --set-mark $zrodlo"; $cid = $cid + 1; $handl = $handl + 1; $zrodlo = $zrodlo + 1; } } # end while } # end if seek } # end for close PLIK_SHIT; system "iptables -t mangle -A UPIER_ETH0 -m mark --mark 0 -j MARK --set-mark 2000";
Edycja:
Wydaje się, iż problemem były zbyt restrykcyjne zasady "iptables".