Jump to content

Recommended Posts

Posted (edited)

eth0 внешний интерфейс.

eth1 внутрений.

 

/sbin/tc qdisc del dev eth0 root 2>/dev/null

/sbin/tc qdisc del dev eth0 ingress 2>/dev/null

/sbin/tc qdisc del dev eth1 root 2>/dev/null

/sbin/tc qdisc del dev eth1 ingress 2>/dev/null

/sbin/tc qdisc del dev ifb0 root 2>/dev/null

/sbin/tc qdisc del dev ifb0 ingress 2>/dev/null

 

$tc qdisc add dev eth1 root handle 1: htb default 1024

$tc class add dev eth1 parent 1:0 classid 1:1 htb rate 1000Mbit

$tc class add dev eth1 parent 1:1 classid 1:10 htb rate 200Mbit

 

$tc filter add dev eth1 parent 1:0 protocol ip u32

 

#Создаем 4 хеш таблицы для каждого октета

$tc filter add dev eth1 parent 1:0 handle 11: protocol ip u32 divisor 256

$tc filter add dev eth1 parent 1:0 handle 12: protocol ip u32 divisor 256

$tc filter add dev eth1 parent 1:0 handle 13: protocol ip u32 divisor 256

 

 

 

#Создаем фильтр направлящий весь трафик в хеш таблицу с ID 10

$tc filter add dev eth1 parent 1:0 protocol ip u32 ht 800:: match ip dst 0.0.0.0/0 hashkey mask 0xff000000 at 16 link 11:

 

#Добавляем правило в 10 хеш таблицу, если первый октет равен 192, то оправляем пакет в 11 хеш таблицу

$tc filter add dev eth1 parent 1:0 protocol ip u32 ht 11:c0: match ip dst 192.0.0.0/8 hashkey mask 0xff0000 at 16 link 12:

 

#Добавляем правило в 11 хеш таблицу, если второй октет равен 168, то оправляем пакет в 12 хеш таблицу

$tc filter add dev eth1 parent 1:0 protocol ip u32 ht 12:a8: match ip dst 192.168.0.0/16 hashkey mask 0xff00 at 16 link 13:

### Конец создания базового шейпера

 

 

Смотрим.

root@gateway:~# tc -s -d filter show dev eth1
filter parent 1: protocol ip pref 49146 u32
filter parent 1: protocol ip pref 49146 u32 fh 806: ht divisor 1
filter parent 1: protocol ip pref 49147 u32
filter parent 1: protocol ip pref 49147 u32 fh 805: ht divisor 1
filter parent 1: protocol ip pref 49148 u32
filter parent 1: protocol ip pref 49148 u32 fh 804: ht divisor 1
filter parent 1: protocol ip pref 49149 u32
filter parent 1: protocol ip pref 49149 u32 fh 13: ht divisor 256
filter parent 1: protocol ip pref 49149 u32 fh 803: ht divisor 1
filter parent 1: protocol ip pref 49150 u32
filter parent 1: protocol ip pref 49150 u32 fh 12: ht divisor 256
filter parent 1: protocol ip pref 49150 u32 fh 12:a8:800 order 2048 key ht 12 bkt a8 link 13:  (rule hit 16723 success 0)
 match c0a80000/ffff0000 at 16 (success 16723 )
   hash mask 0000ff00 at 16
filter parent 1: protocol ip pref 49150 u32 fh 802: ht divisor 1
filter parent 1: protocol ip pref 49151 u32
filter parent 1: protocol ip pref 49151 u32 fh 11: ht divisor 256
filter parent 1: protocol ip pref 49151 u32 fh 11:c0:800 order 2048 key ht 11 bkt c0 link 12:  (rule hit 16723 success 0)
 match c0000000/ff000000 at 16 (success 16723 )
   hash mask 00ff0000 at 16
filter parent 1: protocol ip pref 49151 u32 fh 801: ht divisor 1
filter parent 1: protocol ip pref 49152 u32
filter parent 1: protocol ip pref 49152 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 49152 u32 fh 800::800 order 2048 key ht 800 bkt 0 link 11:  (rule hit 16723 success 0)
 match 00000000/00000000 at 16 (success 16723 )
   hash mask ff000000 at 16
root@gateway:~#

 

Идем дальше:

$tc qdisc add dev eth0 root handle 1: htb default 1024

$tc class add dev eth0 parent 1:0 classid 1:1 htb rate 1000Mbit

$tc class add dev eth0 parent 1:1 classid 1:10 htb rate 200Mbit

 

$tc filter add dev eth0 parent 1:0 protocol ip u32

 

#Создаем 4 хеш таблицы для каждого октета

$tc filter add dev eth0 parent 1:0 handle 11: protocol ip u32 divisor 256

$tc filter add dev eth0 parent 1:0 handle 12: protocol ip u32 divisor 256

$tc filter add dev eth0 parent 1:0 handle 13: protocol ip u32 divisor 256

 

#Создаем фильтр направлящий весь трафик в хеш таблицу с ID 10

$tc filter add dev eth0 parent 1:0 protocol ip u32 ht 800:: match ip src 0.0.0.0/0 hashkey mask 0xff000000 at 12 link 11:

 

#Добавляем правило в 10 хеш таблицу, если первый октет равен 192, то оправляем пакет в 11 хеш таблицу

$tc filter add dev eth0 parent 1:0 protocol ip u32 ht 11:c0: match ip src 192.0.0.0/8 hashkey mask 0xff0000 at 12 link 12:

 

#Добавляем правило в 11 хеш таблицу, если второй октет равен 168, то оправляем пакет в 12 хеш таблицу

$tc filter add dev eth0 parent 1:0 protocol ip u32 ht 12:a8: match ip src 192.168.0.0/16 hashkey mask 0xff00 at 12 link 13:

### Конец создания базового шейпера

#}

 

 

Смотрим статистику:

root@gateway:~# tc -s -d filter show dev eth0

filter parent 1: protocol ip pref 49146 u32

filter parent 1: protocol ip pref 49146 u32 fh 806: ht divisor 1

filter parent 1: protocol ip pref 49147 u32

filter parent 1: protocol ip pref 49147 u32 fh 805: ht divisor 1

filter parent 1: protocol ip pref 49148 u32

filter parent 1: protocol ip pref 49148 u32 fh 804: ht divisor 1

filter parent 1: protocol ip pref 49149 u32

filter parent 1: protocol ip pref 49149 u32 fh 13: ht divisor 256

filter parent 1: protocol ip pref 49149 u32 fh 803: ht divisor 1

filter parent 1: protocol ip pref 49150 u32

filter parent 1: protocol ip pref 49150 u32 fh 12: ht divisor 256

filter parent 1: protocol ip pref 49150 u32 fh 12:a8:800 order 2048 key ht 12 bkt a8 link 13: (rule hit 0 success 0)

match c0a80000/ffff0000 at 12 (success 0 )

hash mask 0000ff00 at 12

filter parent 1: protocol ip pref 49150 u32 fh 802: ht divisor 1

filter parent 1: protocol ip pref 49151 u32

filter parent 1: protocol ip pref 49151 u32 fh 11: ht divisor 256

filter parent 1: protocol ip pref 49151 u32 fh 11:c0:800 order 2048 key ht 11 bkt c0 link 12: (rule hit 0 success 0)

match c0000000/ff000000 at 12 (success 0 )

hash mask 00ff0000 at 12

filter parent 1: protocol ip pref 49151 u32 fh 801: ht divisor 1

filter parent 1: protocol ip pref 49152 u32

filter parent 1: protocol ip pref 49152 u32 fh 800: ht divisor 1

filter parent 1: protocol ip pref 49152 u32 fh 800::800 order 2048 key ht 800 bkt 0 link 11: (rule hit 0 success 0)

match 00000000/00000000 at 12 (success 0 )

hash mask ff000000 at 16

root@gateway:~#

 

 

Такое чувство что тут даже пакеты не доходят до шейпера.

Почему? в чем можно быть косяк?

Edited by Megas

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...
На сайте используются файлы cookie и сервисы аналитики для корректной работы форума и улучшения качества обслуживания. Продолжая использовать сайт, вы соглашаетесь с использованием файлов cookie и с Политикой конфиденциальности.