在Xen Debian 上安裝配置Freeradius2 + Mysql + Daloradi...

安装Debian

#apt-get update
#apt-get -y upgrade

============================================================================
提醒: 以上三行, 只要連上Internet正常, 運行時什麼錯誤都不要管,不斷重複執行就可以.
      可能是互相依賴的關係吧, 偶不是Linux高手, 試過這樣子搞定.
============================================================================

步骤一:安装MySQL并且修改MySQL root密码
#apt-get install mysql-server
中间要求输入密码
 
步骤二:安装Free RADIUS + Free RADIUS MySQL套件
# sudo apt-get install freeradius
# sudo apt-get install freeradius-mysql



在除錯模式運行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

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',server varchar(200) DEFAULT 'Server', PRIMARY KEY (id), KEY nasname (nasname));
mysql>quit

在radius數據庫多加一個ippool表(管理用)

#mysql -uroot -p radius < /etc/freeradius/sql/mysql/ippool.sql

設定 sql.conf
#vim /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
#vim /etc/freeradius/sites-enabled/default
    用sql搜索, 找出以下幾行, 去掉 sql 前的 # 號.
    authorize{} 部份 
    accounting{} 部份
    session{} 部份
    post-auth{} 部份

设置 /etc/freeradius/radiusd.conf

#vim /etc/freeradius/radiusd.conf
注释取消
         $INCLUDE sql.conf



在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 http://jaist.dl.sourceforge.net/sourceforge/daloradius/daloradius-0.9-9.tar.gz
#tar zxvf daloradius-0.9-9.tar.gz
#cp -R daloradius-0.9-9 /var/www

安裝必需軟件包

#apt-get -y install php-pear php5-gd php-DB

設定 Daloradius
#chown -R www-data:www-data /var/www/daloradius-0.9-9 
#chmod 644 /var/www/daloradius-0.9-9/library/daloradius.conf.php

在radius數據庫加入daloradius的表.
#mysql -u root -p radius < /var/www/daloradius-0.9-9/contrib/db/mysql-daloradius.sql

設定 daloradius.conf.php
#vim /var/www/daloradius-0.9-9/library/daloradius.conf.php
    $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 )

#vim /etc/apache2/apache2.conf

在apache2.conf 中加入以下幾行.
==================================================================
  Alias /radius "/var/www/daloradius-0.9-9/"
   <Directory /var/www/daloradius-0.9-9/>
      Options None
      order deny,allow
      deny from all
      allow from 127.0.0.1 
      allow from <other management IP>
 </Directory>
===================================================================

重新啓動apache2.
#/etc/init.d/apache2 restart

打開firefox/ie連接 Daloradius.
登入管理介面.

http://yourip/radius/

用戶: 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-9/mng-list-all.php on line 102

===============================================================================

總算完成!!!  接着就是弄AP-5131了, 沒有AP-5131, 全賣了!!! 等............
測試完了, 在這裡  http://blog.chinaunix.net/u/184/showart.php?id=1907541
以上純粹是個人的安裝配置提供測試的環境, 可能不適合在生產環境裡使用.

參考文件:
http://www.8021xhelp.com/forum/7  
http://www.howtoforge.com/setting-up-a-freeradius-based-aaa-server-with-mysql-and-management-with-daloradius

解决以上错话要建立一个usergroup的表

mysql>CREATE TABLE usergroup (
  username varchar(64) NOT NULL default '',
  groupname varchar(64) NOT NULL default '',
  priority int(11) NOT NULL default '1',
  KEY username (username(32))
) ;

有关client设置

網絡:

DHCP Server:                   172.16.10.1

RADIUS Server:               172.16.10.15

AP :                                  172.16.10.80

在RADIUS Server加入AP.

#vim /etc/freeradius/clients.conf

=====================================================

client 172.16.10.80 {

        secret=symbol

        shortname=AP-5131

}

======================================================

重新啓動Freeradius

#/etc/init.d/freeradius restart

注意:

secret和shortname前用tab键,不能是空格。

如果启动出现了
rlm_sql (sql): database query error, SELECT id, nasname, shortname, type, secret, server FROM nas: Unknown column 'server' in 'field list'
一定是没有这个字段,加上一个即可。

转载于:https://my.oschina.net/shootercn/blog/39775

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值