The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



Индекс форумов
Составление сообщения

Исходное сообщение
"HTB: задержки при перераспределениях траффика"
Отправлено andrew_ronin, 02-Май-06 19:24 
>1. Вышли полностью описание дисциплины и фильтров
>2. Вышли tc -d -s qdisc sh dev XXX
>3. Т.к. у тебя структура класса не иерархическая, то вполне возможно ее
>заменить,
>   например на prio + tc reclassify.

1.
Вот дисциплина шейпинга и вся структура классов (она-таки иерархическая, но я это не упоминал в первом сообщении), а также все фильтры:

#root qdisc
tc qdisc add dev eth0 root handle 1: htb default 6 r2q 1

#root HTB class
tc class add dev eth0 parent 1: classid 1:1 htb rate 128kbit ceil 2048mbit

#HTB classes for traffic categories

tc class add dev eth0 parent 1:1 classid 1:2 htb rate 6kbit ceil 128kbit burst 1k prio 0   #class "interactive"
tc class add dev eth0 parent 1:1 classid 1:3 htb rate 64kbit ceil 128kbit burst 1k prio 1  #class "games"
tc class add dev eth0 parent 1:1 classid 1:4 htb rate 40kbit ceil 64kbit burst 1k prio 2  #class "browsing"
tc class add dev eth0 parent 1:1 classid 1:5 htb rate 12kbit ceil 12kbit burst 1k prio 5  #class "downloads"
tc class add dev eth0 parent 1:1 classid 1:6 htb rate 1kbit ceil 12kbit burst 1k prio 7   #class "default"

#HTB subclasses for traffis subcategories
#subclasses for class "interactive"
tc class add dev eth0 parent 1:2 classid 1:21 htb rate 4kbit ceil 128kbit burst 1k prio 0  #subclass for RDP
tc class add dev eth0 parent 1:2 classid 1:22 htb rate 1kbit ceil 128kbit burst 1k prio 0  #subclass for SSH
tc class add dev eth0 parent 1:2 classid 1:23 htb rate 1kbit ceil 128kbit burst 1k prio 0  #subclass for ICQ

#subclasses for class "games"
tc class add dev eth0 parent 1:3 classid 1:302 htb rate 16kbit ceil 128kbit burst 1k prio 1
tc class add dev eth0 parent 1:3 classid 1:303 htb rate 16kbit ceil 128kbit burst 1k prio 1
tc class add dev eth0 parent 1:3 classid 1:304 htb rate 16kbit ceil 128kbit burst 1k prio 1
tc class add dev eth0 parent 1:3 classid 1:306 htb rate 16kbit ceil 128kbit burst 1k prio 1

#subclasses for class "browsing"
tc class add dev eth0 parent 1:4 classid 1:402 htb rate 4kbit ceil 64kbit burst 1k prio 2
tc class add dev eth0 parent 1:4 classid 1:403 htb rate 4kbit ceil 64kbit burst 1k prio 2
tc class add dev eth0 parent 1:4 classid 1:404 htb rate 4kbit ceil 64kbit burst 1k prio 2
tc class add dev eth0 parent 1:4 classid 1:405 htb rate 4kbit ceil 64kbit burst 1k prio 2
tc class add dev eth0 parent 1:4 classid 1:406 htb rate 4kbit ceil 64kbit burst 1k prio 2
tc class add dev eth0 parent 1:4 classid 1:407 htb rate 4kbit ceil 64kbit burst 1k prio 2
tc class add dev eth0 parent 1:4 classid 1:408 htb rate 4kbit ceil 64kbit burst 1k prio 2
tc class add dev eth0 parent 1:4 classid 1:409 htb rate 4kbit ceil 64kbit burst 1k prio 2
tc class add dev eth0 parent 1:4 classid 1:410 htb rate 4kbit ceil 64kbit burst 1k prio 2

#HTB filters
#filters for class "interactive"
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 506 fw flowid 1:21   #RDP for machine 05
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 705 fw flowid 1:22   #SSH for machine 07
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 207 fw flowid 1:23   #ICQ for machine 02
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 307 fw flowid 1:23   #ICQ for machine 03
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 407 fw flowid 1:23   #ICQ for machine 04
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 507 fw flowid 1:23   #ICQ for machine 05
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 607 fw flowid 1:23   #ICQ for machine 06
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 707 fw flowid 1:23   #ICQ for machine 07
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 807 fw flowid 1:23   #ICQ for machine 08
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 907 fw flowid 1:23   #ICQ for machine 09
tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 1007 fw flowid 1:23  #ICQ for machine 10

#filters for class "games"
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 208 fw flowid 1:302  #LineAge for machine 02
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 308 fw flowid 1:303  #LineAge for machine 03
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 408 fw flowid 1:304  #LineAge for machine 04
tc filter add dev eth0 parent 1:0 prio 1 protocol ip handle 608 fw flowid 1:306  #LineAge for machine 06

#filters for class "browsing"
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 3128 fw flowid 1:4   #HTTP/HTTPS/FTP from Squid
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 201 fw flowid 1:402  #HTTP for machine 02
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 202 fw flowid 1:402  #HTTPS for machine 02
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 301 fw flowid 1:403  #HTTP for machine 03
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 302 fw flowid 1:403  #HTTPS for machine 03
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 401 fw flowid 1:404  #HTTP for machine 04
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 402 fw flowid 1:404  #HTTPS for machine 04
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 501 fw flowid 1:405  #HTTP for machine 05
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 502 fw flowid 1:405  #HTTPS for machine 05
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 601 fw flowid 1:406  #HTTP for machine 06
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 602 fw flowid 1:406  #HTTPS for machine 06
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 701 fw flowid 1:407  #HTTP for machine 07
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 702 fw flowid 1:407  #HTTPS for machine 07
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 801 fw flowid 1:408  #HTTP for machine 08
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 802 fw flowid 1:408  #HTTPS for machine 08
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 901 fw flowid 1:409  #HTTP for machine 09
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 902 fw flowid 1:409  #HTTPS for machine 09
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 1001 fw flowid 1:410 #HTTP for machine 10
tc filter add dev eth0 parent 1:0 prio 2 protocol ip handle 1002 fw flowid 1:410 #HTTPS for machine 10

#filters for class "downloads"
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 203 fw flowid 1:5  #FTP data for machine 02
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 204 fw flowid 1:5  #FTP ctrl for machine 02
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 303 fw flowid 1:5  #FTP data for machine 03
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 304 fw flowid 1:5  #FTP ctrl for machine 03
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 403 fw flowid 1:5  #FTP data for machine 04
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 404 fw flowid 1:5  #FTP ctrl for machine 04
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 503 fw flowid 1:5  #FTP data for machine 05
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 504 fw flowid 1:5  #FTP ctrl for machine 05
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 603 fw flowid 1:5  #FTP data for machine 06
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 604 fw flowid 1:5  #FTP ctrl for machine 06
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 703 fw flowid 1:5  #FTP data for machine 07
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 704 fw flowid 1:5  #FTP ctrl for machine 07
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 803 fw flowid 1:5  #FTP data for machine 08
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 804 fw flowid 1:5  #FTP ctrl for machine 08
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 903 fw flowid 1:5  #FTP data for machine 09
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 904 fw flowid 1:5  #FTP ctrl for machine 09
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 1003 fw flowid 1:5 #FTP data for machine 10
tc filter add dev eth0 parent 1:0 prio 5 protocol ip handle 1004 fw flowid 1:5 #FTP ctrl for machine 10


А вот правила iptables, которые помечают пакеты каждого типа траффика:

iptables -A PREROUTING -s 172.16.0.2 -p tcp --dport 80 -t mangle -j MARK --set-mark 201
iptables -A PREROUTING -s 172.16.0.2 -p tcp --dport 443 -t mangle -j MARK --set-mark 202
iptables -A PREROUTING -s 172.16.0.2 -p tcp --dport 20 -t mangle -j MARK --set-mark 203
iptables -A PREROUTING -s 172.16.0.2 -p tcp --dport 21 -t mangle -j MARK --set-mark 204
iptables -A PREROUTING -s 172.16.0.2 -p tcp --dport 5190 -t mangle -j MARK --set-mark 207
iptables -A PREROUTING -s 172.16.0.2 -p tcp --dport 7777 -t mangle -j MARK --set-mark 208

iptables -A PREROUTING -s 172.16.0.3 -p tcp --dport 80 -t mangle -j MARK --set-mark 301
iptables -A PREROUTING -s 172.16.0.3 -p tcp --dport 443 -t mangle -j MARK --set-mark 302
iptables -A PREROUTING -s 172.16.0.3 -p tcp --dport 20 -t mangle -j MARK --set-mark 303
iptables -A PREROUTING -s 172.16.0.3 -p tcp --dport 21 -t mangle -j MARK --set-mark 304
iptables -A PREROUTING -s 172.16.0.3 -p tcp --dport 5190 -t mangle -j MARK --set-mark 307
iptables -A PREROUTING -s 172.16.0.3 -p tcp --dport 7777 -t mangle -j MARK --set-mark 308

iptables -A PREROUTING -s 172.16.0.4 -p tcp --dport 80 -t mangle -j MARK --set-mark 401
iptables -A PREROUTING -s 172.16.0.4 -p tcp --dport 443 -t mangle -j MARK --set-mark 402
iptables -A PREROUTING -s 172.16.0.4 -p tcp --dport 20 -t mangle -j MARK --set-mark 403
iptables -A PREROUTING -s 172.16.0.4 -p tcp --dport 21 -t mangle -j MARK --set-mark 404
iptables -A PREROUTING -s 172.16.0.4 -p tcp --dport 5190 -t mangle -j MARK --set-mark 407
iptables -A PREROUTING -s 172.16.0.4 -p tcp --dport 7777 -t mangle -j MARK --set-mark 408

iptables -A PREROUTING -s 172.16.0.5 -p tcp --dport 80 -t mangle -j MARK --set-mark 501
iptables -A PREROUTING -s 172.16.0.5 -p tcp --dport 443 -t mangle -j MARK --set-mark 502
iptables -A PREROUTING -s 172.16.0.5 -p tcp --dport 20 -t mangle -j MARK --set-mark 503
iptables -A PREROUTING -s 172.16.0.5 -p tcp --dport 21 -t mangle -j MARK --set-mark 504
iptables -A PREROUTING -s 172.16.0.5 -p tcp --dport 22 -t mangle -j MARK --set-mark 505
iptables -A PREROUTING -s 172.16.0.5 -p tcp --dport 3389 -t mangle -j MARK --set-mark 506
iptables -A PREROUTING -s 172.16.0.5 -p tcp --dport 5190 -t mangle -j MARK --set-mark 507

iptables -A PREROUTING -s 172.16.0.6 -p tcp --dport 80 -t mangle -j MARK --set-mark 601
iptables -A PREROUTING -s 172.16.0.6 -p tcp --dport 443 -t mangle -j MARK --set-mark 602
iptables -A PREROUTING -s 172.16.0.6 -p tcp --dport 20 -t mangle -j MARK --set-mark 603
iptables -A PREROUTING -s 172.16.0.6 -p tcp --dport 21 -t mangle -j MARK --set-mark 604
iptables -A PREROUTING -s 172.16.0.5 -p tcp --dport 5190 -t mangle -j MARK --set-mark 607
iptables -A PREROUTING -s 172.16.0.6 -p tcp --dport 7777 -t mangle -j MARK --set-mark 608

iptables -A PREROUTING -s 172.16.0.7 -p tcp --dport 80 -t mangle -j MARK --set-mark 701
iptables -A PREROUTING -s 172.16.0.7 -p tcp --dport 443 -t mangle -j MARK --set-mark 702
iptables -A PREROUTING -s 172.16.0.7 -p tcp --dport 20 -t mangle -j MARK --set-mark 703
iptables -A PREROUTING -s 172.16.0.7 -p tcp --dport 21 -t mangle -j MARK --set-mark 704
iptables -A PREROUTING -s 172.16.0.7 -p tcp --dport 22 -t mangle -j MARK --set-mark 705
iptables -A PREROUTING -s 172.16.0.7 -p tcp --dport 3389 -t mangle -j MARK --set-mark 706
iptables -A PREROUTING -s 172.16.0.7 -p tcp --dport 5190 -t mangle -j MARK --set-mark 707

iptables -A PREROUTING -s 172.16.0.8 -p tcp --dport 80 -t mangle -j MARK --set-mark 801
iptables -A PREROUTING -s 172.16.0.8 -p tcp --dport 443 -t mangle -j MARK --set-mark 802
iptables -A PREROUTING -s 172.16.0.8 -p tcp --dport 20 -t mangle -j MARK --set-mark 803
iptables -A PREROUTING -s 172.16.0.8 -p tcp --dport 21 -t mangle -j MARK --set-mark 804
iptables -A PREROUTING -s 172.16.0.8 -p tcp --dport 5190 -t mangle -j MARK --set-mark 807

iptables -A PREROUTING -s 172.16.0.9 -p tcp --dport 80 -t mangle -j MARK --set-mark 901
iptables -A PREROUTING -s 172.16.0.9 -p tcp --dport 443 -t mangle -j MARK --set-mark 902
iptables -A PREROUTING -s 172.16.0.9 -p tcp --dport 20 -t mangle -j MARK --set-mark 903
iptables -A PREROUTING -s 172.16.0.9 -p tcp --dport 21 -t mangle -j MARK --set-mark 904
iptables -A PREROUTING -s 172.16.0.9 -p tcp --dport 5190 -t mangle -j MARK --set-mark 907

iptables -A PREROUTING -s 172.16.0.10 -p tcp --dport 80 -t mangle -j MARK --set-mark 1001
iptables -A PREROUTING -s 172.16.0.10 -p tcp --dport 443 -t mangle -j MARK --set-mark 1002
iptables -A PREROUTING -s 172.16.0.10 -p tcp --dport 20 -t mangle -j MARK --set-mark 1003
iptables -A PREROUTING -s 172.16.0.10 -p tcp --dport 21 -t mangle -j MARK --set-mark 1004
iptables -A PREROUTING -s 172.16.0.10 -p tcp --dport 5190 -t mangle -j MARK --set-mark 1007

(для справки: порт 5190 - ICQ, 7777 - игрушка LineAge III).

iptables -t mangle -A OUTPUT -o eth0 -m owner --uid-owner 31 -j MARK --set-mark 3128

(здесь uid-owner 31 соответствует юзеру squid (юзаем транспарент прокси); в иерархии классов он использует тот же класс, что и веб-траффик (1:4); вообще-то при использовании транспарент прокси нет нужды опередлять веб-траффик для каждой машины; здесь это сделано только на случай если возникнет необходимость пустить какую-либо машину в инет напрямую, а не через прокси; в таком случае она будет использовать свой субкласс под общим классом 1:4 (это чтоб траффик, который не идёт через прокси тоже шейпался)).

2.
gate:~ # tc -d -s qdisc show dev eth0
qdisc htb 1: r2q 1 default 6 direct_packets_stat 0 ver 3.17
Sent 2264277 bytes 28123 pkts (dropped 0, overlimits 2947)
gate:~ #

3. Ну, на счёт неиерархичности классов вопрос, кажется снят :-)

 

Ваше сообщение
Имя*:
EMail:
Для отправки новых сообщений в текущей нити на email укажите знак ! перед адресом, например, !user@host.ru (!! - не показывать email).
Более тонкая настройка отправки ответов производится в профиле зарегистрированного участника форума.
Заголовок*:
Сообщение*:
 
При общении не допускается: неуважительное отношение к собеседнику, хамство, унизительное обращение, ненормативная лексика, переход на личности, агрессивное поведение, обесценивание собеседника, провоцирование флейма голословными и заведомо ложными заявлениями. Не отвечайте на сообщения, явно нарушающие правила - удаляются не только сами нарушения, но и все ответы на них. Лог модерирования.



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру