Chinaunix首页 | 论坛 | 博客
  • 博客访问: 128350
  • 博文数量: 4
  • 博客积分: 1560
  • 博客等级: 上尉
  • 技术积分: 315
  • 用 户 组: 普通用户
  • 注册时间: 2004-11-13 15:02
文章分类

全部博文(4)

文章存档

2009年(2)

2008年(2)

我的朋友

分类: 系统运维

2009-04-02 20:15:04

在Ubuntu 8.1上安裝配置Freeradius2 + Mysql + Daloradius
2009/03/29

好久沒有弄與系統有關的東西, 還要在linux上(以前一直用FreeBSD).
由於有個客戶要求演示 Symbol/Motorola 的AP-5131 熱點能不能用RADIUS, 所以試試. 
摸了3個星期, 總算搞定.  參考了一些文件, 在CentOS, FreeBSD, Ubuntu 8.04, 試過很多次都不行. (暈, 太笨了 >.
廢話少說!!  開始吧!!     

1. 安裝 Ubuntu 8.1
安裝不要教了吧, 網上一大堆Linux高手, 自己google吧.
安裝時需要安裝的軟件包.
OpenSSH Server          -->以前的習慣, 用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 < /etc/freeradius/sql/mysql/schema.sql
#mysql -uroot -p
mysql>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 喔! ^^!! )

Daloradius是什麼東東, 就是一個GUI介面的RADIUS用戶管理工具,
主要管理無線網絡熱點用戶.


從SourceForge下載 Daloradius
#cd ~
#wget
#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 < /var/www/daloradius-0.9-8/contrib/db/mysql-daloradius.sql

設定 daloradius.conf.php
#vi /var/www/daloradius-0.9-8/library/daloradius.conf
    $configValues['FREERADIUS_VERSION'] = '2';
    $configValues['CONFIG_DB_ENGINE'] = 'mysql';
    $configValues['CONFIG_DB_HOST'] = '127.0.0.1';
    $configValues['CONFIG_DB_USER'] = '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.
登入管理介面.



用戶: 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://blog.chinaunix.net/u/184/showart.php?id=1907541
以上純粹是個人的安裝配置提供測試的環境, 可能不適合在生產環境裡使用.

參考文件:
 


 
阅读(4345) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

mygod1002009-08-19 19:42:31

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 *

diyself2009-07-24 10:56:44

您的那个错误,应该是没有安装db吧? pear install db