Форум русскоязычного сообщества Ubuntu


Хотите сделать посильный вклад в развитие Ubuntu и русскоязычного сообщества?
Помогите нам с документацией!

Автор Тема: шейпинг с помощью iptables по ip и(или) маку  (Прочитано 2526 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн darzanebor

  • Автор темы
  • Активист
  • *
  • Сообщений: 350
    • Просмотр профиля
Собственно подскажите где инфу найти по теме? Буду благодарен...

Пользователь решил продолжить мысль 08 Августа 2009, 20:35:13:
чтото накопал, но что то не пойму! :>/

Цитировать
/sbin/tc qdisc del dev eth1 root
/sbin/tc qdisc add dev eth1 root handle 2: htb default 200

# Default Class (just in case)
/sbin/tc class add dev eth1 parent 2:0 classid 2:200 htb rate 8Kbit prio 10
/sbin/tc qdisc add dev eth1 parent 2:200 pfifo limit 1024

# Main Class
/sbin/tc class add dev eth1 parent 2:0 classid 2:3 htb rate 256Kbit prio 3
/sbin/tc qdisc add dev eth1 parent 2:3 sfq perturb 10
/sbin/tc filter add dev eth1 parent 2:0 protocol ip prio 1 u32 match ip dst 192.168.0.0/24 flowid 2:3

# 192.168.0.2 setup:
/sbin/tc class add dev eth1 parent 2:3 classid 2:1002 htb rate 128Kbit ceil 256Kbit prio 6
/sbin/tc qdisc add dev eth1 parent 2:1002 pfifo limit 1024
/sbin/tc filter add dev eth1 parent 2:3 protocol ip prio 6 u32 match ip dst 192.168.0.2 flowid 2:1002

# 192.168.0.3 setup:
/sbin/tc class add dev eth1 parent 2:3 classid 2:1003 htb rate 128Kbit ceil 256Kbit prio 6
/sbin/tc qdisc add dev eth1 parent 2:1003 pfifo limit 1024
/sbin/tc filter add dev eth1 parent 2:3 protocol ip prio 6 u32 match ip dst 192.168.0.3 flowid 2:1003
« Последнее редактирование: 08 Августа 2009, 20:35:13 от darzanebor »

Оффлайн Psy[H[]

  • Активист
  • *
  • Сообщений: 883
  • Маньяк. Ставлю Linux на все что попадется под руку
    • Просмотр профиля
Re: шейпинг с помощью iptables по ip и(или) маку
« Ответ #1 : 08 Августа 2009, 20:54:55 »
наткнулся я как-то на мощную псевдографическую мордочку для iptables, называется, кажись, vuurmuur. Там куча наворотов, в том числе и шейпинг. Может, поможет
Я знаю только то, что ничего не знаю.
                                     

Оффлайн darzanebor

  • Автор темы
  • Активист
  • *
  • Сообщений: 350
    • Просмотр профиля
Re: шейпинг с помощью iptables по ip и(или) маку
« Ответ #2 : 09 Августа 2009, 13:49:58 »
Нашел в инете скрипт шейпера, поправил немного под себя, выдает ошибку, скрипт и ошибка внизу, наверно указал не правилно команду tc но как исправить не пойму, подскажите пожалуйста и будет шейпер =)
Шейпер:
Цитировать
#!/bin/bash

DEVUP="eth1"
RATEUP=\"100\"
SFARMRATE=\"100\"
UNCLASSRATE=\"1\"
TARIF1=\"256\"
BURST1=\"260\"

tc qdisc del dev $DEVUP root 2> /dev/null > /dev/null
tc qdisc del dev $DEVUP ingress 2> /dev/null > /dev/null

#Add root discipline to device eth1 -----------------------------------------------------------
tc qdisc add dev $DEVUP root handle 1:0 htb default 200
tc qdisc add dev $DEVUP handle ffff: ingress

#Add root classes to root discipline ----------------------------------------------------------
#Add root class for workstations packets flow
tc class add dev $DEVUP parent 1:0 classid 1:1 htb bandwidth ${RATEUP}mbit
#Add root class for servers packets flow
tc class add dev $DEVUP parent 1:0 classid 1:300 htb bandwidth ${SFARMRATE}mbit
#Add root class to unclassified packets flow
tc class add dev $DEVUP parent 1:0 classid 1:200 htb bandwidth ${UNCLASSRATE}kbit

#Add branch classes to root classes -----------------------------------------------------------
#Add leaf classes to 1:1 root class
# 1. User1
tc class add dev $DEVUP parent 1:1 classid 1:10 htb rate ${TARIF1}kbit burst ${BURST1}kbit  ceil ${RATEUP}mbit
# 2. User2
tc class add dev $DEVUP parent 1:1 classid 1:11 htb rate ${TARIF1}kbit burst ${BURST1}kbit ceil ${RATEUP}mbit

#Servers farm rules-----------------------------------------------------------------------------------
#Add leaf class to 1:300 class
tc class add dev $DEVUP parent 1:300 classid 1:400 htb rate ${SFARMRATE}mbit ceil ${SFARMRATE}mbit

#Add filters -----------------------------------------------------------------------------------------
#Add filter for server farm realm packets flow classification
tc filter add dev $DEVUP protocol ip parent 1:0 prio 1 u32 match ip src 192.168.52.0/25 flowid 1:400

#Add filter for ingress packets flow from workstations
# 1. User1
tc filter add dev $DEVUP protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.52.94 flowid 1:10
# 2. User2
tc filter add dev $DEVUP protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.52.13 flowid 1:11

Ошибка
Цитировать
udo bash /etc/traffpro/traffpro_shaper
[sudo] password for clio:
Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lower are served first {0}
 quantum  how much bytes to serve from leaf at once {use r2q}

TC HTB version 3.3
Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lower are served first {0}
 quantum  how much bytes to serve from leaf at once {use r2q}

TC HTB version 3.3
Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lower are served first {0}
 quantum  how much bytes to serve from leaf at once {use r2q}

TC HTB version 3.3
Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lower are served first {0}
 quantum  how much bytes to serve from leaf at once {use r2q}

TC HTB version 3.3
Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lower are served first {0}
 quantum  how much bytes to serve from leaf at once {use r2q}

TC HTB version 3.3
Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lower are served first {0}
 quantum  how much bytes to serve from leaf at once {use r2q}

TC HTB version 3.3


Оффлайн Tokh

  • Активист
  • *
  • Сообщений: 705
    • Просмотр профиля
Re: шейпинг с помощью iptables по ip и(или) маку
« Ответ #3 : 09 Августа 2009, 14:43:24 »
А слабо код забрать в тег код, вместо тега цитата? ;)

Не догоняю выражение
RATEUP=\"100\"
Для чего стоит символ экрана `\`?
Такая запись по идее делает содержимое переменной RATEUP равным строке `"100"` вместо строки `100`.
Если поставить
RATEUP="100"
то действительно ${RATEUP} будет равно сотне без кавычек.

Как правильно подставлять цифры в параметры tc?
Как правильно должна выглядеть скомпилированная строка
tc class add dev $DEVUP parent 1:0 classid 1:1 htb bandwidth ${RATEUP}mbit?

Я думаю первая ошибка в этом, а дальше... Ну когда-то шейпер будет, это точно. :)
Вроде внутри темы https://forum.ubuntu.ru/index.php?topic=33853.0 было про HTB.
« Последнее редактирование: 09 Августа 2009, 14:51:10 от u-375 »
StarDict и Mueller помогут против английского мануала.

 

Страница сгенерирована за 0.026 секунд. Запросов: 20.