| |||||||||||||||||||||
Ключевые слова: radius, isp, mysql, freebsd, (найти похожие документы)
From: Shamanaev Irek <rh19 at inbox.ru> Newsgroups: email Date: Mon, 13 May 2004 14:31:37 +0000 (UTC) Subject: Установка и настройка FreeRadius + Freenibs + Mysql + MPD Установка и настройка FreeRadius + Freenibs + Mysql + MPD Предыстория стандартная: Нужен был биллинг и позарез и еще вчера. Требования тоже наверно стандартные - зарождалась городская сеть (ethernet - провйдинг) надо было как-то учитвать работу пользователей и выпускать их в инет. Оптимальное решение по моему мнению - VPN. т.к. сразу отпадают траблы с подменой адресов и заменой маков. Биллинг тоже нашел быстро - nibs - уже использовал его на диалапе. Оставалось только прикрутить mpd. Да, собственно "сервер", - Машинка с тремя фейсами, на самом деле хватит и двух - один наружу второй в home-net :). Сам процесс: Нашел описание настройки mpd & freeradius что меня и вдохновило: - Ставим MySQL. Можно сразу сделать базу (описание в комплекте FreeNibs). - Ставим freeradius из портов, (правда меня не совсем устраивал каталог установки посему поставил все в /usr/local/billing но это на любителя). Файлы настройки взяты из FreeNibs, минимальные записи: #cat clients localhost you_password_for_rad_server #cat users DEFAULT Auth-Type := MS-CHAP #cat nibs.conf - что там править и так понятно, но для самых одаренных есть минимум документации в комплекте FreeNibs. radiusd .conf - посмотрите сами, я практически ничего не менял, главное чтобы nibs был прописан. Остальные файлы можно тоже просмотреть и подправить по своему вкусу, даже если нечего править - полезно будет для общего развития :)) - ставим mpd из портов (версия нужна поновее. - обновите порты сначала). Если версия старая - не будет работать вот эта часть конфига: ******************************** *set radius server 127.0.0.1 you_password 1812 1813 *set radius timeout 10 *set radius config /etc/radius.conf *set radius retries 3 ******************************** для реботы mpd необходим netgraf. можете проверить наличие необходимых опций в ядре, но по моему ядро по умолчанию компилиться с поддержкой netgraf. поэтому пересборка ядра не нужна. Конфиги взятые по приведенному выше линку у меня не заработали, поэтому выкладываю свои: #cat mpd.conf default: load client0 load client1 load client2 client0: new pptp0 pptp0 set ipcp ranges 192.168.1.1/32 192.168.2.1/32 load pptp_standart client1: new pptp1 pptp1 set ipcp ranges 192.168.1.2/32 192.168.2.2/32 load pptp_standart client2: new pptp2 pptp2 set ipcp ranges 192.168.1.3/32 192.168.2.3/32 load pptp_standart pptp_standart: set iface disable on-demand set bundle enable multilink set link yes acfcomp protocomp set link no pap chap set link enable chap set link keep-alive 60 180 set ipcp yes vjcomp set ipcp dns ip_address_you_ns_server`s set iface enable proxy-arp set bundle enable compression set ccp yes mppc set ccp yes mpp-e40 set ccp yes mpp-e56 set ccp yes mpp-e128 set ccp yes mpp-stateless set pptp self ip_на котором слушает mdp set pptp enable incoming set pptp disable originate set iface mtu 1500 set link mtu 1500 set radius server 127.0.0.1 you_password_for_rad_server 1812 1813 set radius timeout 10 set radius config /etc/radius.conf - может быть совсем другой set radius retries 3 set bundle enable radius-auth set bundle enable radius-acct #cat mpd.conf pptp0: set link type pptp set pptp enable incoming set pptp disable originate pptp1: set link type pptp set pptp enable incoming set pptp disable originate pptp2: set link type pptp set pptp enable incoming set pptp disable originate Файлы mpd .script и mpd .secret у меня оставлены пустыми. Есть еще один файл - /etc/radius.conf такого содержания: auth localhost you_password_for_rad_server 3 2 acct localhost you_password_for_rad_server 3 2 ------^^^^^^^^^--------- radius_server и mpd работают на одной машине поэтому - localhost. Теперь MPD готов работать с FreeRadius а радиус благодаря FreeNibs - работает с mysql. Что и требовалось. подробноcти - в /var/log PS Данный текст никоим образом не претендует на оригинальность или руководство к действию, просто у меня все это работает и может кому-то окажется полезным. Однако если кто-то захочет его разместить еще где-то - укажите автора :) и налейте пива. (автору а не себе) PPS Текст взят из головы единственным помошником был /bin/cat. Оригинал по адресу - http://www.shamanaev.ru
продолжение. - Установка и настройка FreeRadius + Freenibs + Mysql + MPD После непродолжительно периода эксплуатации выявилась одна оч. существенная проблема - Данные о трафике и снятие денег со счета происходит только при завершении сессии, т.е. клиент имея на счету 1р. может подключиться и качать сколько душе угодно - благо не диалап :). На сайте nibs-a нашел упоминание о патче для мпд. вот ссылка - http://sourceforge.net/tracker/index.php?func=detail&aid=937956&group_id=14145&atid=314145 Из описания: 1) Offering correct IP address to the client in case mpd is configured to get it from the RADIUS, while the RADIUS does not send Framed-IP-Address attrubute. In this case the original version of the mpd offers to the client 0.0.0.0 as her IP address, which makes impossible to establish the link. 2) The possibility to send Accounting-Update packets to the RADIUS not only on time basis but also depending upon the volume of the received or transferred traffic (or both). Both "update-limit-in" and "update-limit-out" parameters defaults to 0. To set non-zero values one must do it in mpd.conf: set radius update-limit-in X set radius update-limit-out Y (where X, Y - are the traffic in bytes) Then, when the moment for the next-in-turn acct-update time comes, it is checked whether the limits are exceedeed. If they are not exceeded, update is not made (i.e. acct-update packets are not sent to RADIUS). The idea of it: not to overload the RADIUS and its logs. 3) Give ppp netgraph node name like "mpd-<name>" instead of "mpd<pid>-<name>". As the name length of netgraph node is restricted by 15 symbols, and the standard designation ppp node consists of "mpdNNNNN-pptpXX", more than 99 nodes can not be made. Patch makes it possible to solve this problem. 4) Dropping the connection, if the RADIUS has sent vendor-specific attribute 154. When the attribute is 0 it means the continuation of the connection, when it is set to 1 -- the connection should be dropped. The following lines should be added to the dictionary.mpd (VENDOR mpd 12341): ----- ATTRIBUTEDrop-User154integermpd VALUEDrop-UserNo0 VALUEDrop-UserYes1 ----- 5) New function RadiusGetCurrentParams(). In the patch this function gets the Accounting-Response from the RADIUS and marks the moment when connection should be dropped ("Drop-User = Yes" attribute arrival). Hence, any developer may write additional code to this function to catch the reception of attributes she is interested with. The function RadiusGetParams() from the original mpd is used during the (re-)initialization phase only. 3. Mini - How-To 1) Update limits This option may be interesting for those who use the tarification of the traffic. When update limits are non-zero a comparatively little time interval for acct-update can be configured and the required "update-limit-[in]|[out]" established. Internal statistics in mpd works once a minute in any case. That's why, if the line set radius acct-update 60 is added to mdp.conf, mpd gets practically no additional work. The concrete limit values are certainly different for eveyone. But the initial values from 100000 to 1000000 seem quite reasonable to me. After that analyse the results and change the values. Up to individual limits per link. Hint: update limits work only when acct-update is switched on! 2) Drop-user This option may be useful for those, who: - limit clients' traffic, and NAS does not support attribute Session-Octets-Limit; - use dynamic restrictions (formed, for example, by billing system): one login for several simultaneous sessions with the limitation by the time or/and by the traffic; in other cases when it is impossible to determine the restrictions at the beginning of the session. For mpd to drop the link, RADIUS must send this mere attribute with the value "Yes". But, possibly, not the RADIUS itself, but the billing system is responsible for the construction of such packet. That system processes accounting packets of the three types: Start, Stop, Update. "Stop" is of no interest in this context. "Start" employs other determination methods to see if mpd may start the session. It is reasonable to consider only "Update"-packets. When the limits are reached it is quite enough to add to the packet, meant to send the response to the RADIUS, the neccessary pair with the operator "=". Something like: New_Pair = Pair_Create("Drop-User", "Yes", T_OP_EQ); Pair_Add(Pairs_To_Reply, New_Pair); This technology was tested with freeradius-0.9.3, freenibs-0.0.3-bf3. The latter (open-source billing system) can be found at: http://nibs.net.ua, http://sourceforge.net/projects/nibs The patch, allowing to form the neccessary response to the RADIUS for the subsequent transmission to mpd daemon. And as the result to drop the connection: -------- --- rlm_nibs.c.origMon Apr 12 22:27:58 2004 +++ rlm_nibs.cTue Apr 13 01:01:41 2004 @@ -1139,6 +1139,8 @@ radlog(L_INFO, querystr); if (nibs_error != NULL) free(nibs_error); nibs_user_kill(inst, request); + pair = pairmake("Drop-User", "Yes", T_OP_EQ); + pairadd(&request->reply->vps, pair); } } -------- Boris Samorodov, bsam@ipt.ru Т.е. все что нам необходимо, включая патч для модуля freenibs. Встает все без проблем и работает,( - чего и вам желаю.)
| |||||||||||||||||||||
|
|