PF и ограничение трафика для группы.

Обсуждаем OS FreeBSD и сервисы на ней.

PF и ограничение трафика для группы.

Сообщение Андрей » 16 авг 2009, 19:07

Привет всем.
Многие провайдеры сталкиваются с такой проблемой, что число абонентов растет, абоненты требуют все большие скорости, а вот обеспечить данную ширину полосы провайдер не в состоянии, да и затраты на полосу сильно возрастают. В итоге рано или поздно провайдер прибегает к такой мере, как ограничить трафик для определенной группы абонентов.
Итак.
Дано:
1. Канал собственного провайдера. Ширина 50 мбит/с.
2. 25 абонентов подключенных к тарифному плану со скоростью 1 мбит/с.
Задача:
Выделить посредствам pf из канала шириной в 50 мбит/с полосу размером 18 мбит/с на группу состоящую из тех самых 25 человек.

Знаю что на роутерах CISCO это все делается за пару команд.

Подскажите как решить проблему?
Заранее благодарен.
.ı|ı..ı|ı.
Андрей
местный житель
 
Сообщения: 1028
Зарегистрирован: 14 янв 2009, 13:37
Откуда: Оренбургская область

Re: PF и ограничение трафика для группы.

Сообщение root » 17 авг 2009, 12:40

С уважением, root

Изображение
------------
www.mega-net.ru - IT аутсорсинг
Аватара пользователя
root
Site Admin
 
Сообщения: 1894
Зарегистрирован: 11 июн 2008, 13:05
Откуда: Moscow, Russia

Re: PF и ограничение трафика для группы.

Сообщение Андрей » 17 авг 2009, 18:19

Спасибо за линк. В принципе все нормально описано.
Скоро буду пробовать воплотить идею в жизнь.
.ı|ı..ı|ı.
Андрей
местный житель
 
Сообщения: 1028
Зарегистрирован: 14 янв 2009, 13:37
Откуда: Оренбургская область

Re: PF и ограничение трафика для группы.

Сообщение Андрей » 07 окт 2009, 09:37

Приветствую.
Все что описано по линку же больше ориентирован на приоритезацию трафика, а не на шейпирование.
Может как-то можно сделать шейпирование при помощи pf другими способами ?
.ı|ı..ı|ı.
Андрей
местный житель
 
Сообщения: 1028
Зарегистрирован: 14 янв 2009, 13:37
Откуда: Оренбургская область

Re: PF и ограничение трафика для группы.

Сообщение root » 07 окт 2009, 10:45

Андрей писал(а):Все что описано по линку же больше ориентирован на приоритезацию трафика, а не на шейпирование.

не знаю как ты читал приведенный линк, но:
altq и queue и есть шейпирование
создание очереди, что приводит к задержкам, а значит и к снижению скорости

Queueing is configured in pf.conf. There are two types of directives that are used to configure queueing:

* altq on - enables queueing on an interface, defines which scheduler to use, and creates the root queue
* queue - defines the properties of a child queue

The syntax for the altq on directive is:

altq on interface scheduler bandwidth bw qlimit qlim \
tbrsize size queue { queue_list }


* interface - the network interface to activate queueing on.
* scheduler - the queueing scheduler to use. Possible values are cbq and priq. Only one scheduler may be active on an interface at a time.
* bw - the total amount of bandwidth available to the scheduler. This may be specified as an absolute value using the suffixes b, Kb, Mb, and Gb to represent bits, kilobits, megabits, and gigabits per second, respectively or as a percentage of the interface bandwidth.
* qlim - the maximum number of packets to hold in the queue. This parameter is optional. The default is 50.
* size - the size of the token bucket regulator in bytes. If not specified, the size is set based on the interface bandwidth.
* queue_list - a list of child queues to create under the root queue.

For example:

altq on fxp0 cbq bandwidth 2Mb queue { std, ssh, ftp }

This enables CBQ on the fxp0 interface. The total bandwidth available is set to 2Mbps. Three child queues are defined: std, ssh, and ftp.
С уважением, root

Изображение
------------
www.mega-net.ru - IT аутсорсинг
Аватара пользователя
root
Site Admin
 
Сообщения: 1894
Зарегистрирован: 11 июн 2008, 13:05
Откуда: Moscow, Russia

Re: PF и ограничение трафика для группы.

Сообщение Андрей » 09 окт 2009, 06:01

Я правильно понял что надо указывать в этом списке адреса машин?
.ı|ı..ı|ı.
Андрей
местный житель
 
Сообщения: 1028
Зарегистрирован: 14 янв 2009, 13:37
Откуда: Оренбургская область

Re: PF и ограничение трафика для группы.

Сообщение root » 09 окт 2009, 10:42

в каком списке то ?

Андрей
прочти мануал внимательнее и пробуй, пробуй, читай снова, пробуй
только так ты сможешь понять, если будешь пробовать, а не рассуждать

можно набрать в гугле: pf.conf altq пример и глянуть примеры
С уважением, root

Изображение
------------
www.mega-net.ru - IT аутсорсинг
Аватара пользователя
root
Site Admin
 
Сообщения: 1894
Зарегистрирован: 11 июн 2008, 13:05
Откуда: Moscow, Russia

Re: PF и ограничение трафика для группы.

Сообщение Андрей » 10 окт 2009, 19:44

А можно ли это сделать средствами mpd5?
Или все же только pf?
.ı|ı..ı|ı.
Андрей
местный житель
 
Сообщения: 1028
Зарегистрирован: 14 янв 2009, 13:37
Откуда: Оренбургская область

Re: PF и ограничение трафика для группы.

Сообщение root » 11 окт 2009, 10:40

Андрей писал(а):А можно ли это сделать средствами mpd5?
Или все же только pf?

ограничить пропускную способность можно не одним способом
что бы ответить на твой вопрос, опять же нужно открыть мануал и почитать его, например:


RADIUS ACL's

Mpd can use the Access Control Lists (ACLs) given by the RADIUS server. This ACLs may include ipfw rules, pipes, queues and tables and also mpd internal traffic filtering/shaping/limiting features. That two sets are redundant. ipfw proposed as standard and universal solution, while internal filter/shaper/limiter based on ng_bpf+ng_car expected to work faster with big number of active links.

ipfw

You can write in your RADIUS configuration something like:

mpd-table += "1=10.0.0.1",
mpd-table += "1=10.0.0.15",
mpd-pipe += "1=bw 10Kbyte/s",
mpd-pipe += "5=bw 20Kbyte/s",
mpd-rule += "1=pipe %p1 all from any to table\\(%t1\\) in",
mpd-rule += "2=pipe %p5 all from table\\(%t1\\) to any out",
mpd-rule += "100=allow all from any to any",

When mpd receives these parameters it will call ipfw(8) to create firewall rules, pipes and queues with unique numbers starting from 10000 (configurable via 'set global start...'). %rX, %pX, %qX, %tX macroses will be expanded within mpd-rule and mpd-queue. To the end of each rule will be added "via ngX" to make the rule apply only to that client's networking interface.

As a result of this example we would get these commands executed:

ipfw table 32 add 10.0.0.1
ipfw table 32 add 10.0.0.15
ipfw pipe 10000 config bw 10Kbyte/s
ipfw pipe 10001 config bw 20Kbyte/s
ipfw add 10000 pipe 10000 all from any to table\(32\) in via ng0
ipfw add 10001 pipe 10001 all from table\(32\) to any out via ng0
ipfw add 10002 allow all from any to any via ng0

When the link goes down, all created rules will be removed.

Note: As soon as mpd executes ipfw commands using shell, shell's special characters like "(" and ")" must be slashed.

internal (ng_bpf/ng_car)

Mpd can create complex per-interface traffic filtering/limiting engines inside netgraph when it is requested by mpd-filter and mpd-limit RADIUS attributes.

mpd-filter attribute is a packet filter declaration for using in mpd-limit. mpd-filter consists of two main parts: match/nomatch verdict and the condition. tcpdump (libpcap) expression syntax used for conditions.

mpd-filter: match|nomatch {condition}

mpd-limit attribute is an action which should be done for packet. It consists of two main parts: filter and action.

mpd-limit: {filter} {action}

Filter can be or "all" (any packet) or "fltX" (packets matching to specified mpd-filter).

filter: any|fltX

Action can be: "pass" (stop processing and pass packet), "deny" (stop processing and drop packet), "rate-limit" (do Cisco-like rate-limit), "shape" (do simple RED aware traffic shaping).

Actions "rate-limit" and "shape" can have optional "pass" suffix to stop processing after doing this action.

action: pass | deny | rate-limit {rate(bits/s)} [{normal burst(bytes)} [{extended burst(bytes)}]] [pass] | shape {rate(bits/s)} [{burst(bytes)}] [pass]

As example you can write in your RADIUS configuration something like:

mpd-filter += "1#1=nomatch src net 10.0.0.0/24",
mpd-filter += "1#2=match src net 10.0.0.0/10",
mpd-filter += "2#1=match dst net 10.0.0.0/16",
mpd-filter += "2#2=match dst net 11.0.0.0/8",
mpd-limit += "in#1=flt1 pass",
mpd-limit += "in#2=flt2 shape 64000 4000 pass",
mpd-limit += "in#3=all deny",
mpd-limit += "out#1=flt2 pass",
mpd-limit += "out#2=all rate-limit 1024000 150000 300000",
mpd-limit += "out#3=all pass",

As result, one ng_bpf node will be created to implement traffic filters and several (two for this example) ng_car nodes for traffic shaping and rate-limiting. Incoming traffic from 10.0.0.0/10 except 10.0.0.0/24 will be passed, traffic to 10.0.0.0/16 and 11.0.0.0/8 will be shaped to 64Kbits/s, all other will be denied. Outgoing traffic to 10.0.0.0/16 and 11.0.0.0/8 will be passed, all other will be limited to 1024Kbit/s.


каждый выбирает тот способ, с которым ему удобно работать
кто то вышеописанный, кто то отдельно pf, кто то отдельно ipfw и т.д. и т.п.
С уважением, root

Изображение
------------
www.mega-net.ru - IT аутсорсинг
Аватара пользователя
root
Site Admin
 
Сообщения: 1894
Зарегистрирован: 11 июн 2008, 13:05
Откуда: Moscow, Russia

Re: PF и ограничение трафика для группы.

Сообщение Андрей » 11 окт 2009, 21:36

Код: Выделить всё
internal (ng_bpf/ng_car)
Mpd can create complex per-interface traffic filtering/limiting engines inside netgraph when it is requested by mpd-filter and mpd-limit RADIUS attributes.
mpd-filter attribute is a packet filter declaration for using in mpd-limit. mpd-filter consists of two main parts: match/nomatch verdict and the condition. tcpdump (libpcap) expression syntax used for conditions.
mpd-filter: match|nomatch {condition}
mpd-limit attribute is an action which should be done for packet. It consists of two main parts: filter and action.
mpd-limit: {filter} {action}
Filter can be or "all" (any packet) or "fltX" (packets matching to specified mpd-filter).
filter: any|fltX
Action can be: "pass" (stop processing and pass packet), "deny" (stop processing and drop packet), "rate-limit" (do Cisco-like rate-limit), "shape" (do simple RED aware traffic shaping).
Actions "rate-limit" and "shape" can have optional "pass" suffix to stop processing after doing this action.
action: pass | deny | rate-limit {rate(bits/s)} [{normal burst(bytes)} [{extended burst(bytes)}]] [pass] | shape {rate(bits/s)} [{burst(bytes)}] [pass]
As example you can write in your RADIUS configuration something like:
mpd-filter += "1#1=nomatch src net 10.0.0.0/24",
mpd-filter += "1#2=match src net 10.0.0.0/10",
mpd-filter += "2#1=match dst net 10.0.0.0/16",
mpd-filter += "2#2=match dst net 11.0.0.0/8",
mpd-limit += "in#1=flt1 pass",
mpd-limit += "in#2=flt2 shape 64000 4000 pass",
mpd-limit += "in#3=all deny",
mpd-limit += "out#1=flt2 pass",
mpd-limit += "out#2=all rate-limit 1024000 150000 300000",
mpd-limit += "out#3=all pass",
As result, one ng_bpf node will be created to implement traffic filters and several (two for this example) ng_car nodes for traffic shaping and rate-limiting. Incoming traffic from 10.0.0.0/10 except 10.0.0.0/24 will be passed, traffic to 10.0.0.0/16 and 11.0.0.0/8 will be shaped to 64Kbits/s, all other will be denied. Outgoing traffic to 10.0.0.0/16 and 11.0.0.0/8 will be passed, all other will be limited to 1024Kbit/s.


Перечитал 3 раза, перевел в 3х переводчиках.
Проблема в одном.

Код: Выделить всё
mpd-filter += "1#1=nomatch src net 10.0.0.0/24",
mpd-filter += "1#2=match src net 10.0.0.0/10",
mpd-filter += "2#1=match dst net 10.0.0.0/16",
mpd-filter += "2#2=match dst net 11.0.0.0/8",
mpd-limit += "in#1=flt1 pass",
mpd-limit += "in#2=flt2 shape 64000 4000 pass",
mpd-limit += "in#3=all deny",
mpd-limit += "out#1=flt2 pass",
mpd-limit += "out#2=all rate-limit 1024000 150000 300000",
mpd-limit += "out#3=all pass",

Правильно ли я понял, что тут указывается скорость конкретно для подсетей?
Как же тогда быть в моем случае, что для определенной группы туннелей (на которых ширина полосы пропускания 1 мбит/с) выделять определеный лимит?
Я ведь не могу определенных людей выделить в определенную группу средствами виланов, на которые выдавать определенную ширину канала.

Может как-то можно более удобно указывать людей?
И желательно более автоматизированно (дабы не добавлять клиентов в ручную).

Заранее благодарю за ответ.

З.Ы. Гуглил с запросом об очереди в МПД - не нашел ни одного подходящего ответа.
.ı|ı..ı|ı.
Андрей
местный житель
 
Сообщения: 1028
Зарегистрирован: 14 янв 2009, 13:37
Откуда: Оренбургская область

След.

Вернуться в FreeBSD

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 29

cron