grfmaniak Posted June 26, 2013 Posted June 26, 2013 Есть freeradius в режиме прокси, стоит между микротиком и биллингом, который содержит свой радиус и работает с кучей цисковских насов. Freeradius вырезает ненужные атрибуты из пакетов, и вполне успешно. Но понадобилось еще и скорость ограничивать по тарифам для логинящихся юзеров. Биллинг выдает данные для лимитов в виде Cisco-AVPair, а микротик ждет скоростей в другом виде - Mikrotik-Rate-Limit. Пытаюсь отловить AVPair и на лету сформировать из них Mikrotik-Rate-Limit, однако подходящих средств не нашел, максимум замена значения атрибута. Кто-нибудь решал такую задачку? Вставить ник Quote
agr Posted June 26, 2013 Posted June 26, 2013 http://freeradius.org/radiusd/man/unlang.html через if-else или switch-case ловите значения Cisco-AVPair и делайте update ответа с соответствующими значениями Mikrotik-Rate-Limit. Вставить ник Quote
grfmaniak Posted June 27, 2013 Author Posted June 27, 2013 через if-else или switch-case ловите значения Cisco-AVPair и делайте update ответа с соответствующими значениями Mikrotik-Rate-Limit. Пытаюсь: rad_recv: Access-Accept packet from host 172.16.25.15 port 34009, id=20, length=314 Session-Timeout = 0 Service-Type = Framed-User Framed-Protocol = PPP Framed-IP-Address = 172.16.23.2 Framed-IP-Netmask = 255.255.255.255 Class = 0x353234 Acct-Interim-Interval = 60 Cisco-AVPair = "lcp:interface-config#1=rate-limit output access-group 122 256000 8000 16000 conform-action transmit exceed-action drop" Cisco-AVPair = "lcp:interface-config#2=rate-limit input access-group 123 256000 8000 16000 conform-action transmit exceed-action drop" # Executing section post-proxy from file /etc/freeradius/sites-enabled/default +- entering group post-proxy {...} [post_proxy_log] expand: /var/log/freeradius/radacct/%{Client-IP-Address}/post-proxy-detail-%Y%m%d -> /var/log/freeradius/radacct/172.16.24.1/post-proxy-detail-20130627 [post_proxy_log] /var/log/freeradius/radacct/%{Client-IP-Address}/post-proxy-detail-%Y%m%d expands to /var/log/freeradius/radacct/172.16.24.1/post-proxy-detail-20130627 [post_proxy_log] expand: %t -> Thu Jun 27 17:46:02 2013 ++[post_proxy_log] returns ok [attr_filter.post-proxy] expand: %{Realm} -> test attr_filter: Matched entry test at line 103 ++[attr_filter.post-proxy] returns updated [eap] No pre-existing handler found ++[eap] returns noop ++- entering policy rewrite.avpair {...} +++? if ("%{Cisco-AVPair[1]}" =~ /^.*lcp.*$/ ) expand: %{Cisco-AVPair[1]} -> ? Evaluating ("%{Cisco-AVPair[1]}" =~ /^.*lcp.*$/) -> FALSE +++? if ("%{Cisco-AVPair[1]}" =~ /^.*lcp.*$/ ) -> FALSE +++- entering else else {...} ++++[noop] returns noop +++- else else returns noop ++- policy rewrite.avpair returns noop Должна же была отловиться строка "lcp:interface-config#2=", но почему-то FALSE. Куда копать? Вставить ник Quote
agr Posted June 27, 2013 Posted June 27, 2013 expand: %{Cisco-AVPair[1]} -> Сервер не распознает указанный атрибут. В доке указано: Once the variable is instantiated, it is added to an appropriate attribute list, as described below. ... Where <list> is one of "request", "reply", "control", "proxy-request", "proxy-reply", or "outer.request", "outer.reply", "outer.control", "outer.proxy-request", or "outer.proxy-reply". just as with the "update" section, above. The "<list>:" prefix is optional, and if omitted, is assumed to refer to the "request" list. Ваш пакет не является запросом, поэтому нужно задать явно префикc, указывающий принадлежность атрибута списку атрибутов. Вставить ник Quote
grfmaniak Posted June 28, 2013 Author Posted June 28, 2013 Ваш пакет не является запросом, поэтому нужно задать явно префикc, указывающий принадлежность атрибута списку атрибутов. Все получилось, гран мерси :) Вставить ник Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.