天天看點

Linux上建構freeradius

文章轉載自:百度空間

RADIUS伺服器軟體可以從多個地方獲得。使用FreeRADIUS(請參閱參考資料獲得相關連結),FreeRADIUS是來自開放源碼社群的一種強大的Linux上的RADIUS伺服器,可用于如今的分布式和異構計算環境。FreeRADIUS 1.0.2 支援LDAP、MySQL、PostgreSQL和Oracle資料庫,并與諸如EAP和Cisco LEAP之類的網絡協定相容。FreeRADIUS目前被部署在很多大型生産網絡系統中。

下面的步驟示範如何在Red Hat Enterprise Linux Advanced Server 3.0上安裝和測試FreeRADIUS 1.0.2:

清單1 安裝和測試FreeRADIUS

tar -zxvf freeradius-1.0.2.tar.gz - extract it with gunzip and tar./configuremakemake install - run this command as rootradiusd or - start RADIUS serverradiusd -X - start RADIUS server in debug moderadtest test test localhost 0 testing123 - test RADIUS server

如果radtest收到一個響應,則表明FreeRADIUS伺服器工作正常。

配置FreeRADIUS

RADIUS伺服器的配置包括對伺服器、客戶機和使用者的配置(都是用于驗證和授權)。出于不同的需要,對RADIUS伺服器可以有不同的配置。幸運的是,大多數配置都是類似的。

* 配置伺服器

FreeRADIUS配置檔案通常位于/etc/raddb檔案夾下。首先,我們需要像下面這樣修改radiusd.conf檔案。

清單2 修改radiusd.conf

1) Global settings:log_auth = yes - log authentication requests to the log filelog_auth_badpass = no - don't log passwords if request rejectedlog_auth_goodpass = no - don't log passwords if request accepted2) LDAP Settings:modules { ldap { server = "bluepages.ibm.com" - the hostname or IP address of the LDAP server port = 636 - encrypted communications basedn = "ou=bluepages,o=ibm.com" - define the base Distinguished Names (DN), - under the Organization (O) "ibm.com", - in the Organization Unit (OU) "bluepages" filter = "(mail=%u)" - specify search criteria base_filter = "(objectclass=person)" - specify base search criteria }authenticate { - enable authentication against LDAP Auth-Type LDAP { ldap }

參數被設為使用 IBM BluePages,這是LDAP服務的一個執行個體。對于其他LDAP伺服器,參數可能有所不同。

* 配置客戶機

客戶機是在/etc/raddb/clients.conf 檔案中配置的。有兩種方式可用于配置RADIUS客戶機。您可以按IP subnet将NAS分組(清單 3),或者可以按主機名或 IP 位址列出NAS(清單4)。如果按照第二種方法,可以定義shortname和nastype。

清單3 按IP subnet将NAS分組

client 192.168.0.0/24 { secret = mysecret1 - the "secret" should be the same as configured on NAS shortname = mylan - the "shortname" can be used for logging nastype = cisco - the "nastype" is used for checkrad and is optional}

清單4 按主機名或 IP 位址列出 NAS

client 192.168.0.1 { secret = mysecret1 shortname = myserver nastype = other}

* 為驗證而配置使用者

檔案 /etc/raddb/user 包含每個使用者的驗證和配置資訊。

清單5 /etc/raddb/user 檔案

1) Authentication type:Auth-Type := LDAP - authenticate against LDAPAuth-Type := Local, User-Password == "mypasswd" - authenticate against the - password set in /etc/raddb/userAuth-Type := System - authenticate against the system password file - /etc/passwd or /etc/shadow2) Service type:Service-Type = Login, - for administrative login

* 為授權而配置使用者

下面的驗證伺服器屬性-值對(AV)應該為使用者授權而進行配置。在驗證被接受後,這個屬性-值對被傳回給NAS,作為對管理者登入請求的響應。

對于Cisco路由器,有不同的權限級别:

級别1是無特權(non-privileged)。提示符是 router>,這是用于登入的預設級别。

級别15是特權(privileged)。 提示符是 router#,這是進入 enable 模式後的級别。

級别2到14 在預設配置中不使用。

下面的指令可以使一個使用者從網絡通路伺服器登入,并獲得對EXEC指令的立即通路:

cisco-avpair ="shell:priv-lvl=15" 

下面的代碼處理相同的任務,這一次是對于Cisco無線通路點:

Cisco:Avpair= "aironet:admin-capability=write+snmp+ident+firmware+admin" 

任何功能組合都和這個屬性一起傳回:

Cisco:Avpair = "aironet:admin-capability=ident+admin"

Cisco:Avpair = "aironet:admin-capability=admin" 

請與 Cisco 聯系,以獲得關于這些指令的更多資訊。

配置網絡通路伺服器

接下來我們将配置NAS,首先是配置一個Cisco路由器,然後輪到一個Cisco WAP。

對于Cisco IOS 12.1路由器,我們将啟用AAA,然後配置驗證、授權和記帳。

清單6 啟用AAA

aaa new-modelradius-server host 192.168.0.100radius-server key mysecret1

AAA 在路由器上應該被啟用。然後,指定能為 NAS 提供 AAA 服務的 RADIUS 伺服器的清單。加密密鑰用于加密 NAS 和 RADIUS 伺服器之間的資料傳輸。它必須與 FreeRADIUS 上配置的一樣。

清單7 配置驗證

aaa authentication login default group radius localline vty 0 4login authentication default

在這個例子中,網絡管理者使用 RADIUS 驗證。如果 RADIUS 伺服器不可用,則使用 NAS 的本地使用者資料庫密碼。

清單8 配置授權

aaa authorization exec default group radius if-authenticated

允許使用者在登入到 NAS 中時運作 EXEC shell。

清單9 配置記帳

aaa accounting system default start-stop group radiusaaa accounting network default start-stop group radiusaaa accounting connection default start-stop group radiusaaa accounting exec default stop-only group radiusaaa accounting commands 1 default stop-only group radiusaaa accounting commands 15 default wait-start group radius

必須對路由器進行特别的配置,以使之發送記帳記錄到RADIUS伺服器。使用清單9中的指令記錄關于NAS系統事件、網絡連接配接、輸出連接配接、EXEC操作以及級别1和級别15上的指令的記帳資訊。

這樣就好了。現在讓我們看看為Cisco無線通路點而進行的配置。下面的配置适用于帶有Firmware 12.01T1的Cisco 1200 Series AP。如圖2中的螢幕快照所示,您:

* 輸入伺服器名或 IP 位址和共享的秘密。

* 選擇“Radius”作為類型,并選中“User Authentication”。

實際上,在這裡您還可以配置EAP Authentication,使FreeRADIUS可用于驗證無線LAN的一般使用者。

記帳:工作中的RADIUS

現在所有配置都已經完成,FreeRADIUS伺服器可以開始記錄NAS發送的所有資訊,将該資訊存儲在/var/log/radius/radius.log檔案中,就像這樣:

清單10 /var/log/radius/radius.log檔案

Thu Mar 3 21:37:32 2005 : Auth: Login OK: [David] (from client mylan port 1 cli 192.168.0.94)Mon Mar 7 23:39:53 2005 : Auth: Login incorrect: [John] (from client mylan port 1 cli 192.168.0.94)

詳細的記帳資訊被存放在/var/log/radius/radacct目錄中。清單11表明,David在2005年3月4日19:40到19:51這段時間裡從 192.168.0.94登入到了路由器192.168.0.1。這麼詳細的資訊對于正在調查安全事故以及試圖維護易于審計的記錄的管理者來說無疑是一大幫助。

清單11 RADIUS 提供的記帳細節示例

Fri Mar 4 19:40:12 2005 NAS-IP-Address = 192.168.0.1 NAS-Port = 1 NAS-Port-Type = Virtual User-Name = "David" Calling-Station-Id = "192.168.0.94" Acct-Status-Type = Start Acct-Authentic = RADIUS Service-Type = NAS-Prompt-User Acct-Session-Id = "00000026" Acct-Delay-Time = 0 Client-IP-Address = 192.168.0.1 Acct-Unique-Session-Id = "913029a52dacb116" Timestamp = 1109936412Fri Mar 4 19:51:17 2005 NAS-IP-Address = 192.168.0.1 NAS-Port = 1 NAS-Port-Type = Virtual User-Name = "David" Calling-Station-Id = "192.168.0.94" Acct-Status-Type = Stop Acct-Authentic = RADIUS Service-Type = NAS-Prompt-User Acct-Session-Id = "00000026" Acct-Terminate-Cause = Idle-Timeout Acct-Session-Time = 665 Acct-Delay-Time = 0 Client-IP-Address = 192.168.0.1 Acct-Unique-Session-Id = "913029a52dacb116" Timestamp = 1109937077

結束語

通過遵循本文中列出的簡單步驟,您可以建立一個Remote Authentication Dial-In User Service伺服器,該伺服器使用一個外部的LDAP伺服器來處理為網絡安全問題而進行的驗證、授權和記帳。