- 論壇徽章:
- 0
|
在Ubuntu 8.1上安裝配置Freeradius2 + Mysql + Daloradius
2009/03/29
好久沒有弄與系統(tǒng)有關(guān)的東西, 還要在linux上(以前一直用FreeBSD).
由於有個客戶要求演示 Symbol/Motorola 的AP-5131 熱點(diǎn)能不能用RADIUS, 所以試試.
摸了3個星期, 總算搞定. 參考了一些文件, 在CentOS, FreeBSD, Ubuntu 8.04, 試過很多次都不行. (暈, 太笨了 >.以前的習(xí)慣, 用putty連接, cli?簡單.
No automatic update -->不清楚啦, 總之不想更新就是了.
加root用戶 -->以前學(xué)linux的習(xí)慣, 不用打sudo嘛.
#sudo passwd root
2. 配置前更新 Ubuntu 8.1
#apt-get update
#apt-get -y upgrade
#aptitude install fakeroot
============================================================================
提醒: 以上三行, 只要連上Internet正常, 運(yùn)行時什麼錯誤都不要管,不斷重複執(zhí)行就可以.
可能是互相依賴的關(guān)係吧, 偶不是Linux高手, 試過這樣子搞定.
============================================================================
3. Freeradius 安裝
#apt-get -y install freeradius*
更改 radiusd.conf (Ubuntu 的預(yù)設(shè)是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
==========================================
在除錯模式運(yùn)行Freeradius
#freeradius -X
應(yīng)該看到累似以下的東西
============================================================
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
運(yùn)行Freeradius
#/etc/init.d/freeradius start
用系統(tǒng)用戶查詢(預(yù)設(shè)是用系統(tǒng)帳號)
#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安裝完成能運(yùn)行.
3. 安裝配置Mysql與Freeradius
安裝Mysql及其他軟件包
#apt-get -y install mysql-server phpmyadmin vim-full
phpmyadmin要求安裝web伺服器, apache, apache2, lighttp自已選. 這裡用apache2
在Mysql加radius數(shù)據(jù)庫及用戶
#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數(shù)據(jù)庫多加一個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
設(shè)定 sql.conf
#vi /etc/freeradius/sql.conf
================================================================================
# Connection info:
server = "localhost"
login = "radius" --> radius用戶名
password = "radpass" --> radius密碼
radius_db = "radius" --> radius數(shù)據(jù)庫
使用NAS管理, 把以這行前面的 # 去掉.
readclients = yes
================================================================================
設(shè)定 /etc/freeradius/sites-enabled/default
#vi /etc/freeradius/sites-enabled/default
用sql搜索, 找出以下幾行, 去掉 sql 前的 # 號.
authorize{} 部份 ( 第 152 行 )
accounting{} 部份 ( 第 342 行 )
session{} 部份 ( 第 373 行)
post-auth{} 部份 ( 第 394 行 )
在radius數(shù)據(jù)庫加用戶
#mysql -uroot -p
mysql> use radius;
mysql> INSERT INTO radcheck (UserName, Attribute, Value) VALUES ('sqltest', 'Password', 'testpwd');
mysql> FLUSH PRIVILEGES;
mysql> quit
在除錯模式測試查詢radius數(shù)據(jù)庫的用戶
停用freeradius.
#/etc/init.d/freeradius stop
運(yùn)行Freeradius除錯模式
#freeradius -X
Freeradius運(yùn)行時應(yīng)該加入數(shù)據(jù)庫部份, 若果出現(xiàn)任何錯誤, Freeradius將停止運(yùn)行.
應(yīng)該會看到累似以下的東西
==================================================================
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on proxy address * port 1814
Ready to process requests.
==================================================================
打開一個新的終端測試查詢radius數(shù)據(jù)庫的用戶
#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
看到以上的結(jié)果就成功了.
4. 安裝 Daloradius (不是 Doraemon 喔! ^^!! )
Doraemon是什麼東東, 就是一個GUI介面的RADIUS用戶管理工具,
主要管理無線網(wǎng)絡(luò)熱點(diǎn)用戶.
從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
設(shè)定 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數(shù)據(jù)庫加入daloradius的表.
#mysql -u root -p radius radius用戶名
$configValues['CONFIG_DB_PASS'] = 'radpass'; --> radius密碼
$configValues['CONFIG_DB_NAME'] = 'radius'; --> radius數(shù)據(jù)庫
在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博客,如果查看原文請點(diǎn):http://blog.chinaunix.net/u/184/showart_1889008.html |
|