linux上構建freeradius,網上搜索的

本人菜鳥一枚,這幾天在搗鼓FreeRADIUS。已經根據網上一些牛人的帖子,成功的在MySQL中添加賬戶和密碼,並能夠用“radtest”命令測試成功。但是最後在交換機上配置完AAA後,用“test aaa group radius zbx zbx new-code”測試的時候發現不可達。拓撲如下:是用GNS3模擬cisco的交換機,連接vitrialBox的虛擬網卡(redhat系統的)。

2012-05-17 17 13 19.jpg 
先說說我的機子環境和FreeRADIUS的版本:REDhat企業版5.0;freeradius是freeradius-server-2.1.12的。
一、服務器中所做的配置如下:

1. 創建radius數據庫

create database radius;

2. 導入表

mysql -u root -p radius < /usr/local/etc/raddb/sql/mysql/schema.sql

mysql -u root -p radius < /usr/local/etc/raddb/sql/mysql/nas.sql

  

3. 修改default文件

authorize{} accounting {}中的sql前面的#去掉,並把authorize{} 中的files前加#

4. 修改sql.conf

這個加上sql root和密碼

5. 修改clients.conf文件,路徑/usr/local/etc/raddb/clients.conf

client 127.0.0.1 {

secret = testing123

shortname = localhost

nastype = other

}

添加了這個,這是我配置的交換機的地址。

client 192.168.1.254 {

secret = testing123

shortname = radiusclient

}

client 192.168.1.0/24 {

secret = testing123

shortname = private-network

}

6.  修改radius.conf,在目錄/usr/local/etc/raddb/radiusd.conf

刪除$INCLUDE sql.conf前的“#” ,使其加載sql.conf

7.  創建數據庫的東西

mysql> insert into radgroupreply (groupname,attribute,op,value) values ('user','Auth-Type',':=','Local');

mysql> insert into radgroupreply (groupname,attribute,op,value) values ('user','Service-Type',':=','Framed-User');

建立用戶信息:

mysql> insert into radcheck (username,attribute,op,value) values (zbx','User-Password',':=','zbx'); 將用戶加入組中:

mysql> insert into radusergroup (username,groupname) values ('zbx','user');

8. 測試radius

radtest test test localhost 0 testing123【圖片好像有點模糊,就是ACCEPT的。】

2012-05-17 22 27 45.png


二、交換機的配置

端口配置,可以互相ping通。

int f0/1
switchport mode access
spanning-tree portfast
int f0/0
switchport mode access
spanning-tree portfast
exit
int vlan 1
ip add 172.16.1.254 255.255.255.0
no shutdown


aaa配置:

aaa new-model 
aaa authentication login default group radius local
radius-server host 172.16.1.1 key testing123
aaa authorization network default group radius local
dot1x system-auth-control 
int f0/0
switch mode access
dot1x port-control auto



配置完成後,測試的時候發現“AAA server is not reachable”
我嘗試打開debug aaa authentication 和debug aaa protocol radius,看不太懂debug信息。不過我覺得沒什麼參考價值,因爲連接不上服務器。
也嘗試抓包,只發現Access-requst的請求包,和返回的icmp的不可達的包。
在這個過程中,我也打開radius的debug(radiusd -X),一點消息都沒有。

不知道是什麼問題呢?請問我該如何配置,讓NAS連接上服務器?

另外,我發現在radius下,用radiusd -X打開debug模式的時候,發現最後幾句是這樣的。
... adding new socket proxy address * port 32778
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on command file /usr/local/var/run/radiusd/radiusd.sock
Listening on authentication address 127.0.0.1 port 18120 as server inner-tunnel
Listening on proxy address * port 1814
Ready to process requests.

是不是說,radius會監聽這些端口?
我在交換機上,發現配置完aaa沒打開debug的時候,發現下面兩句話:
*Mar  1 01:22:29.519: %RADIUS-4-RADIUS_DEAD: RADIUS server 172.16.1.1:1645,1646 is not responding.
*Mar  1 01:22:29.523: %RADIUS-4-RADIUS_ALIVE: RADIUS server 172.16.1.1:1645,1646 has returned.
這是什麼意思呢?1645和1646是交換機發包的端口嗎?
這樣就沒被radius監聽到嗎?




hi,我從iteye上看到了你的評論

1、radius server的防火牆iptables有沒有打開?因爲server在radiusd -X的時候沒有接收到任何客戶端的請求信息,所以要麼就是server的防火牆阻止了,要麼就是交換機到radius server的網絡不通(這個你可以在交換機上ping下server看看)
另端口確實是auth:1812,acct:1813

2、radius server配置那塊,因爲你的交換機地址是172.16.1.154,所以client.conf裏的
client 192.168.1.254 {
secret = testing123
shortname = radiusclient
}
應該改成
client 172.16.1.254 {
secret = testing123
shortname = radiusclient
}

先把第一個搞定了,再進行第二步,調試的時候server那邊以以debug開啓radiusd,注意查看輸出信息



我把iptables關閉了,果然就可以了。問題2中的client地址是被我貼出來的時候打錯的,沒有問題。再次感謝!

發佈了19 篇原創文章 · 獲贊 3 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章