Freeradius測試環境搭建
AAA服務器和RADIUS協議
AAA(Authentication,Authorization,Accounting)驗證,受權,記帳。AAA服務器主要功能是:哪些用戶具備訪問權限,具備訪問權限的用戶 又能夠訪問哪些服務,對用戶正在使用的網絡資源進行計帳。
RADIUS(Remote Authentication Dial In User Service)協議是惟一的AAA標準。RADIUS協議是基於UDP的一種客戶機/服務器協議。RADIUS客戶機是網絡訪問服務器,它一般是一個路由器,交換機或者無線訪問點。RADIUS服務器一般是運行在linux或Windows服務器上的一個監護程序。 RADIUS協議的認證端口是1812,記帳端口是1813。
RADIUS協議的特色:
1. Client/Server模式
RADIUS協議是C/S結構協議,客戶端是把用戶信息傳遞給RADIUS服務器,並負責執行返回的響應。 RADIUS服務器負責接受用戶的請求,對用戶身份進行認證,併爲客戶端返回全部爲用戶提供服務所必須的配置信息。RADIUS服務器能夠爲其餘的RADIUS Server擔當代理。
2. 網絡安全
客戶端和RADIUS服務器之間的交互通過共享密鑰認證,另外避免有人在網絡上監聽獲取用戶密碼,客戶端和服務器以前的任何的通訊都是通過加密後傳輸的。
3. 認證機制
RADIUS服務器能夠採用多種認證方式鑑別用戶的合法性,當用戶提供了用戶名密碼後,RADIUS服務器能夠支持點對點的PAP認證(PPP PAP),點對點的CHAP認證(PPP CHAP),UNIX的登錄操做(UNIX Login)和其餘認證機制。
RADIUS的工做過程:
1. 用戶輸入用戶名密碼等信息到客戶端
2. 客戶端產生一個接入請求報文到RADIUS服務器,其中包含了用戶名,密碼,客戶端ID和用戶訪問端口的ID,密碼都是通過MD5加密的。
3. RADIUS服務器對用戶進行認證
4. 若是認證成功,RADIUS服務器想客戶端發送容許接入包,不然就發送拒絕接入包。
5. 若客戶端接受到容許接入包,則爲用戶創建鏈接,對用戶進行受權和提供服務;若接受到拒絕接入包,則拒絕用戶接入請求。
6. 客戶端發送計費請求給RADIUS服務器
7. RADIUS服務器接受到計費請求包後開始計費,並向客戶端回送開始計費的響應包。
8. 用戶斷開鏈接,客戶端發送中止計費包給RADIUS服務器
9. RADIUS服務器接收到中止計費包後中止計費,並向客戶端發送中止計費響應包,完成該用戶的一次計費,記錄計費信息。
Freeradius的安裝配置
Freeradius是開源免費並徹底兼容RADIUS協議的RADIUS服務器和客戶端軟件,能夠用它對用戶的接入和訪問特定的網絡進行有效的控制,受權,計費等等,它支持多種驗證,包括文件,LDAP,數據庫等等。
測試環境:
192.168.2.97 freeradius server
192.168.2.226 test.com(域服務器)
192.168.2.110 測試client
配置hosts文件,freeradius測試時須要解析主機名
192.168.2.226 test.com
192.168.2.97 freeradius.test.com
修改freeradius的主機名
[root@lamp ~]# vim /etc/sysconfig/network
HOSTNAME=freeradius.test.com
Freeradius與AD結合須要用的組件有freeradius,samba,krb5-server,直接yum安裝以上組件便可,安裝samba krb5-server freeradius2 freeradius2-util
-
[root@lamp ~]
-
[root@lamp ~]
-
[global]
-
workgroup = test
-
realm = test.com
-
netbios name = freeradius
-
security = ads
-
password server = testtest.test.com
-
winbind separator = +
-
idmap uid = 10000-20000
-
idmap gid = 10000-20000
-
winbind enum users = yes
-
winbind enum groups = yes
-
nt acl support = yes
-
winbind cache time = 0
-
template shell = /bin/bash
-
template homedir = /home/%D/%U
-
winbind use default domain =yes
-
[homes]
-
comment = Home Directories
-
path = /home/%D/%U
-
browseable = no
-
writable = yes
-
-
valid users = %U
-
[root@freeradius ~]
-
passwd: files winbind
-
shadow: files winbind
-
-
group: files winbind
-
[root@lamp ~]
-
[libdefaults]
-
default_realm = test.COM
-
dns_lookup_realm = false
-
dns_lookup_kdc = false
-
ticket_lifetime = 24h
-
forwardable = yes
-
[realms]
-
test.COM = {
-
kdc = testtest.test.com:88
-
admin_server = testtest.test.com:749
-
default_domain = test.com
-
}
-
[domain_realm]
-
.example.com = EXAMPLE.COM
-
-
example.com = test.COM
-
[root@lamp ~]
-
[realms]
-
test.COM = {
-
-
acl_file = /var/kerberos/krb5kdc/kadm5.acl
-
dict_file = /usr/share/dict/words
-
admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
-
supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hm
-
ac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal des-cbc-crc:v4 des-cbc
-
-crc:afs3
-
-
}
-
[root@lamp ~]
-
-
Password for administrator@test.COM:
-
若是沒有什麼報錯就說明通訊正常。
-
[root@freeradius ~]
-
Starting SMB services: [ OK ]
-
Starting NMB services: [ OK ]
-
[root@freeradius ~]
-
[root@freeradius ~]
-
-
[root@freeradius ~]
-
[root@freeradius ~]
-
Password:
-
-
Joined domain test.
-
[root@freeradius ~]
-
-
checking the trust secret via RPC calls succeeded
-
[root@freeradius ~]
-
administrator
-
guest
-
krbtgt
-
ddclic
-
test01
-
test02
-
[root@freeradius ~]
-
BUILTIN+administrators
-
BUILTIN+users
-
domain computers
-
domain controllers
-
schema admins
-
-
enterprise admins
-
[root@freeradius ~]
-
test1:*:10033:10008:test1:/home/test/test1:/bin/bash
-
test2:*:10034:10008:test2:/home/test/test2:/bin/bash
-
test3:*:10035:10008:test3:/home/test/test3:/bin/bash
-
test4:*:10036:10008:test4:/home/test/test4:/bin/bash
-
-
test5:*:10037:10008:test5:/home/test/test5:/bin/bash
-
-
-
[root@freeradius ~]
-
-
[root@freeradius ~]
-
exec ntlm_auth {
-
wait = yes
-
program = "/usr/bin/ntlm_auth --request-nt-key --domain=test.COM --username=%{mschap
-
:User-Name} --password=%{User-Password}"
-
-
} }
-
[root@freeradius ~]
-
authenticate {
-
ntlm_auth
-
}
-
[root@freeradius ~]
-
authenticate {
-
ntlm_auth
-
-
}
-
[root@freeradius ~]
-
-
DEFAULT Auth-Type = ntlm_auth
-
[root@freeradius ~]
-
policy {
-
-
-
ntlm_auth.authorize {
-
if (!control:Auth-Type && User-Password) {
-
update control {
-
Auth-Type := ntlm_auth
-
}
-
}
-
}
-
-
}
-
[root@freeradius ~]
-
[root@freeradius ~]
-
Sending Access-Request of id 48 to 127.0.0.1 port 1812
-
User-Name = "test"
-
User-Password = "123456"
-
NAS-IP-Address = 192.168.2.97
-
NAS-Port = 0
-
Message-Authenticator = 0x00000000000000000000000000000000
-
-
rad_recv: Access-Reject packet from host 127.0.0.1 port 1812, id=48, length=20
-
-
[root@freeradius ~]
-
-
-
-
[root@freeradius ~]
-
ntlm_auth = "/usr/bin/ntlm_auth --request-nt-key --username=%{mschap:User-Name:-None} --domain=%{%{mschap:NT-Domain}:-test.COM} --challenge=%{%{mschap:Challenge}:-00} --n
-
-
t-response=%{%{mschap:NT-Response}:-00}"
-
-
[root@freeradius ~]
-
Sending Access-Request of id 127 to 127.0.0.1 port 1812
-
User-Name = "test"
-
NAS-IP-Address = 192.168.2.97
-
NAS-Port = 0
-
Message-Authenticator = 0x00000000000000000000000000000000
-
MS-CHAP-Challenge = 0x0f1ec04f5f7f3ec2
-
MS-CHAP-Response = 0x000100000000000000000000000000000000000000000000000085c8068f30dcb423d1e6f7ed5db18b53a1d321ceb8f2266c
-
rad_recv: Access-Reject packet from host 127.0.0.1 port 1812, id=127, length=38
-
-
MS-CHAP-Error = "\000E=691 R=1"
-
-
Exec-Program output: winbind client not authorized to use winbindd_pam_auth_crap. Ensure permissions on /var/cache/samba/winbindd_privileged are set correctly. (0xc0000022)
-
-
Exec-Program-Wait: plaintext: winbind client not authorized to use winbindd_pam_auth_crap. Ensure permissions on /var/cache/samba/winbindd_privileged are set correctly. (0xc0000022)
-
-
[root@freeradius ~]
-
[root@freeradius samba]
-
[root@freeradius samba]
-
Shutting down Winbind services: [ OK ]
-
Starting Winbind services: [ OK ]
-
-
[root@freeradius ~]
-
-
[root@freeradius samba]
-
Sending Access-Request of id 231 to 127.0.0.1 port 1812
-
User-Name = "test"
-
NAS-IP-Address = 192.168.2.97
-
NAS-Port = 0
-
Message-Authenticator = 0x00000000000000000000000000000000
-
MS-CHAP-Challenge = 0x58a8d7e945e9ed8f
-
MS-CHAP-Response = 0x00010000000000000000000000000000000000000000000000000fcd072553b1813344cbe6d3fc3fe5e1ecbf853eaf5a4a03
-
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=231, length=84
-
MS-CHAP-MPPE-Keys = 0x0000000000000000c2bea7b13efd39e82dcd04478fb185370000000000000000
-
MS-MPPE-Encryption-Policy = 0x00000001
-
-
MS-MPPE-Encryption-Types = 0x00000006