免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4564 | 回复: 0

在Ubuntu 8.1上安裝配置Freeradius2 + Mysql + Daloradius [复制链接]

论坛徽章:
0
发表于 2009-04-02 20:15 |显示全部楼层

                                                                                                                                在Ubuntu 8.1上安裝配置Freeradius2 + Mysql + Daloradius
2009/03/29
好久沒有弄與系統有關的東西, 還要在linux上(以前一直用FreeBSD).
由於有個客戶要求演示 Symbol/Motorola 的AP-5131 熱點能不能用RADIUS, 所以試試.
摸了3個星期, 總算搞定.  參考了一些文件, 在CentOS, FreeBSD, Ubuntu 8.04, 試過很多次都不行. (暈, 太笨了 >.以前的習慣, 用putty連接, cli?簡單.
No automatic update     -->不清楚啦, 總之不想更新就是了.
加root用戶               -->以前學linux的習慣, 不用打sudo嘛.
#sudo passwd root
2. 配置前更新 Ubuntu 8.1
#apt-get update
#apt-get -y upgrade
#aptitude install fakeroot
============================================================================
提醒: 以上三行, 只要連上Internet正常, 運行時什麼錯誤都不要管,不斷重複執行就可以.
      可能是互相依賴的關係吧, 偶不是Linux高手, 試過這樣子搞定.
============================================================================
3. Freeradius 安裝
#apt-get -y install freeradius*
更改 radiusd.conf  (Ubuntu 的預設是radiusd, 不是用freeradius)
#vi /etc/freeradius/radiusd.conf  
==========================================
run_dir = ${localstatedir}/run/radiusd
把radiusd更改成freeradius
run_dir = ${localstatedir}/run/freeradius
pidfile = ${run_dir}/radiusd.pid
把radiusd更改成freeradius
pidfile = ${run_dir}/freeradius.pid
==========================================
在除錯模式運行Freeradius
#freeradius -X
應該看到累似以下的東西
============================================================
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on proxy address * port 1814
Ready to process requests.
============================================================
按 CTRL + C 離開.
測試Freeradius
運行Freeradius
#/etc/init.d/freeradius start
用系統用戶查詢(預設是用系統帳號)
#radtest {用戶} {密碼} localhost 1812 testing123
# radtest kin 123 localhost 1812 testing123
Sending Access-Request of id 138 to 127.0.0.1 port 1812
        User-Name = "kin"
        User-Password = "123"
        NAS-IP-Address = 127.0.1.1
        NAS-Port = 1812
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=138, length=20
Freeradius安裝完成能運行.
3. 安裝配置Mysql與Freeradius
安裝Mysql及其他軟件包
#apt-get -y install mysql-server phpmyadmin vim-full
phpmyadmin要求安裝web伺服器, apache, apache2, lighttp自已選. 這裡用apache2

在Mysql加radius數據庫及用戶
#mysqladmin -uroot -p create radius
#mysql -uroot -p
mysql>GRANT ALL ON radius.* TO 'radius'@'localhost' IDENTIFIED BY 'radpass';
mysql>FLUSH PRIVILEGES;
mysql>quit
在radius數據庫多加一個nas表(管理用)
#mysql -uroot -p radius use radius;
mysql>CREATE TABLE nas (id int(10) NOT NULL auto_increment, nasname varchar(128) NOT NULL, shortname varchar(32), type varchar(30) DEFAULT 'other', ports int(5), secret varchar(60) DEFAULT 'secret' NOT NULL, community varchar(50), description varchar(200) DEFAULT 'RADIUS Client', PRIMARY KEY (id), KEY nasname (nasname));
mysql>quit
設定 sql.conf
#vi /etc/freeradius/sql.conf
================================================================================
# Connection info:
server = "localhost"
login = "radius"           --> radius用戶名
password = "radpass"       --> radius密碼
radius_db = "radius"       --> radius數據庫
使用NAS管理, 把以這行前面的 # 去掉.
readclients = yes
================================================================================
設定 /etc/freeradius/sites-enabled/default
#vi /etc/freeradius/sites-enabled/default
    用sql搜索, 找出以下幾行, 去掉 sql 前的 # 號.
    authorize{} 部份 ( 第 152 行 )
    accounting{} 部份 ( 第 342 行 )
    session{} 部份 ( 第 373 行)
    post-auth{} 部份 ( 第 394 行 )
在radius數據庫加用戶
#mysql -uroot -p
mysql> use radius;
mysql> INSERT INTO radcheck (UserName, Attribute, Value) VALUES ('sqltest', 'Password', 'testpwd');
mysql> FLUSH PRIVILEGES;
mysql> quit
在除錯模式測試查詢radius數據庫的用戶
停用freeradius.
#/etc/init.d/freeradius stop
運行Freeradius除錯模式
#freeradius -X
Freeradius運行時應該加入數據庫部份, 若果出現任何錯誤, Freeradius將停止運行.
應該會看到累似以下的東西
==================================================================
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on proxy address * port 1814
Ready to process requests.
==================================================================
打開一個新的終端測試查詢radius數據庫的用戶
#radtest sqltest testpwd localhost 1812 testing123
Sending Access-Request of id 226 to 127.0.0.1 port 1812
        User-Name = "sqltest"
        User-Password = "testpwd"
        NAS-IP-Address = 127.0.1.1
        NAS-Port = 1812
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=226, length=20
看到以上的結果就成功了.
4. 安裝 Daloradius (不是 Doraemon 喔! ^^!! )
Doraemon是什麼東東, 就是一個GUI介面的RADIUS用戶管理工具,
主要管理無線網絡熱點用戶.
從SourceForge下載 Daloradius
#cd ~
#wget
http://jaist.dl.sourceforge.net/sourceforge/daloradius/daloradius-0.9-8.tar.gz
#tar zxvf daloradius-0.9-8.tar.gz
#cp -R daloradius-0.9-8 /var/www
安裝必需軟件包
#apt-get -y install php-pear php5-gd php-DB
設定 Daloradius
#chown -R www-data:www-data /var/www/daloradius-0.9-8
#chmod 644 /var/www/daloradius-0.9-8/library/daloradius.conf.php
在radius數據庫加入daloradius的表.
#mysql -u root -p radius  radius用戶名
    $configValues['CONFIG_DB_PASS'] = 'radpass';   --> radius密碼
    $configValues['CONFIG_DB_NAME'] = 'radius';    --> radius數據庫
在apache2 加虛擬目錄( Alias )
#vi /etc/apache2/apache2.conf
在apache2.conf 中加入以下幾行.
==================================================================
  Alias /myradius "/var/www/daloradius-0.9-8/"
   
      Options None
      order deny,allow
      deny from all
      allow from 127.0.0.1
      allow from

===================================================================
重新?動apache2.
#/etc/init.d/apache2 restart
打開firefox/ie連接 Daloradius.
登入管理介面.
http://yourip/myradius/
用戶: administrator
密碼: radius
這部分只成功了一半, 可以新加, 搜索和更改用戶, 但不能列出所有用戶.
自己不懂sql, 所以不能搞定.  希望有哪位大大搞定.
以下是列出用戶的錯誤信息.
===============================================================================
Users Listing +
Listing users in database
Database error
Error Message: DB Error: no such table
Debug info: SELECT distinct(radcheck.username),radcheck.value, radcheck.id,usergroup.groupname as groupname, radcheck.attribute, userinfo.firstname, userinfo.lastname FROM radcheck LEFT JOIN userinfo ON radcheck.username=userinfo.username LEFT JOIN usergroup ON radcheck.username=usergroup.username WHERE (Attribute LIKE '%-Password') OR (Attribute='Auth-Type') GROUP BY UserName [nativecode=1146 ** Table 'radius.usergroup' doesn't exist]
Fatal error: Call to undefined method DB_Error::numRows() in /var/www/daloradius-0.9-8/mng-list-all.php on line 102
===============================================================================
總算完成!!!  接着就是弄AP-5131了, 沒有AP-5131, 全賣了!!! 等............
參考文件:
http://www.8021xhelp.com/forum/7
  
http://www.howtoforge.com/setting-up-a-freeradius-based-aaa-server-with-mysql-and-management-with-daloradius

               
               
               
               
               
               
               
               
               
               
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/184/showart_1889008.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP