亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 19515 | 回復: 9
打印 上一主題 下一主題

[ldap] Freeradius+OpenLDAP+PEAP認證 [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2008-07-17 11:01 |只看該作者 |倒序瀏覽
文檔介紹:


本文參考:
Extreme Networks Technical Brief 文檔號:TBLDAPEnviron_1370
http://www.nabble.com 討論列表也給了我很大的幫助,很多關于Freeradius和OpenLDAP保存數(shù)據(jù)的概念都在此討論區(qū)中弄明白的。對于文中所涉及的radius概念或是一些名詞請借助google幫助學習,文中沒有更詳細的解釋。

關于:
公司原用認證服務器為Soliton Net'Attest EPS,知道為什么EPS證書一直不能正確導入到VISTA中,這點是從廠商方面得到的證明,不知道是什么特別的原因。再加上EPS更換產(chǎn)品的空白服務器,讓我感覺有些郁悶,所以公司決定更換現(xiàn)在公司的認證系統(tǒng),包括DHCP服務器。
這是到公司后第二個自己獨立完成的比較完整的公司網(wǎng)絡改造過程,記錄一下方便自己以后查閱,也希望能為準備用Freeradius認證和OpenLDAP的朋友提供一些有用的信息。
介于網(wǎng)絡上流行的一些關于Freeradius+OpenLDAP+PEAP認證的一些資料都比較舊,所以在測試的時候Freeradius采用最新的Freeradius 2.0.5版本。由于2.0以前的版本配置文件格式和文件出入比較大,所以使用Freeradius2.0以前版本的朋友在配置的時候需要特別注意。CentOS下用yum安裝后為1.1.7版。

目的:
Freeradius在公司使用不是做為WLAN接認證,而是做為LAN接入認證用。先要通過認證后才能通論DHCP獲得IP,而且會因為Freeradius返回的信息為Client劃分VLAN ID以及訪問控制。

感謝:
首先是老婆對我生活上的細心照顧,才能讓我有更多的時間學習和測試來完成這份文檔。Freeradius的測試大部分在下班之后才能進行,所以每天晚上回家都很晚,老婆也一直等到我回家后才吃晚飯,另外要感謝遠在國內(nèi)的父母,生活在異鄉(xiāng)的我們正因為有你們的牽掛,我們會更加努力。

===========================分割線==========================

服務器環(huán)境:
CentOS 5.1 Linux blackduck 2.6.18-53.el5
#安裝時不含任何安裝包
yum –y update
#全部更新升級
openssl.i686 0.9.8b-10.el5
openssl-devel.i386 0.9.8b-10.el5
openldap.i386 2.3.27-8.el5_2.4
openldap-clients.i386 2.3.27-8.el5_2.4
openldap-devel.i386 2.3.27-8.el5_2.4
openldap-servers.i386 2.3.27-8.el5_2.4

對于OpenLDAP的配置可以參看我以前的文檔《Samba+LDAP+LAM管理工具應用》一文件中OpenLDAP的配置

Freeradius 安裝:
下載源碼包
#wget ftp://ftp.freeradius.org/pub/fre ... erver-2.0.5.tar.bz2
#tar –jxvf freeradius-server-2.0.5.tar.bz2
#cd freeradius-server-2.0.5
#./configure --with-openssl --with-openssl-includes=/usr/include/openssl/ \
--with-openssl-libraries=/usr/lib/openssl/
#configure文件中說明配置支持OpenSSL但是裝完后運行EAP支持的時候會報錯。說手動沒有支持OpenSSL,所以此處給出OpenSSL的路徑。
#make && make install

安裝后可以直接執(zhí)行進行測試
#radiusd –Xf   (2.0以前版本為-AXf  X為Debug模式 f為不運行在deamon狀態(tài)下 )

===========================分割線==========================

安裝后可以通過radtest測試
#radtest admin password localhost 0 testing123
返回信息如下說明測試成功,此步很重要,安裝后第一步應該測試一下Freeradius是不是可以正常運行,再進行下面的配置。
Sending Access-Request of id 85 to 127.0.0.1 port 1812
        User-Name = "admin"
        User-Password = "password"
        NAS-IP-Address = 127.0.0.1
        NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=85, length=20


測試通過后配置Freeradius,配置文件在/usr/local/etc/raddb下,2.0之后的配置對于對認證的支持方式采用模塊化,所以修改起來也很方便。配置文件忽略注釋項

主配置文件radiusd.conf:
#vi radiusd.conf
此文件只是把log選項中的認證log信息打開了其他部分沒有做任何修改
log {
        destination = files
file = ${logdir}/radius.log
        syslog_facility = daemon
        stripped_names = no
        auth = yes
        auth_badpass = no
        auth_goodpass = no
}

2.0以后的版本,所以有的認證模塊都保存在/usr/local/etc/raddb/modules目錄下
用戶認證配置文件

===========================分割線==========================

ldap認證模塊修改:
#vi ldap
比較重要的為前四行,設置你LDAP服務器的配置,如何過慮User-Name的字段,以前你LDAP的搜索域,如果你的LDAP需要權限控制才能訪問,請修改配置文件中被注釋的兩行。
ldap {
        server = "localhost"
        #identity = "cn=admin,o=My Org,c=UA"
        #password = mypass
        basedn = "dc=yepn,dc=net"
        filter = "(uid=%{Stripped-User-Name:-%{User-Name}})"
        base_filter = "(objectclass=radiusprofile)"
        ldap_connections_number = 15
        timeout = 4
        timelimit = 3
        net_timeout = 1
        tls {
               start_tls = no
        }
        dictionary_mapping = ${confdir}/ldap.attrmap
}

紅色文件比較重要,這個表示在檢索LDAP時查找的字段和返回的信息值,對于Client的網(wǎng)絡配置部分都在這文件中表明,后文會詳細說明。

===========================分割線==========================

Freeradius字典文件修改:
通過LDAP認證時的返回值全部都要在Freeradius Dictionary中說明,否側(cè)不能被Freeradius識別。
Dictionary配置文件保存在/usr/local/etc/raddb目錄下
#cat dictionary |grep -v “#”
$INCLUDE        /usr/local/share/freeradius/dictionary

Dictionary文件分部保存在/usr/local/share/freeradius/文件中
#cat dictionary |grep -v “#”
$INCLUDE dictionary.compat
$INCLUDE dictionary.rfc2865
$INCLUDE dictionary.rfc2866
$INCLUDE dictionary.rfc2867
$INCLUDE dictionary.rfc2868
$INCLUDE dictionary.rfc2869
$INCLUDE dictionary.rfc3162
$INCLUDE dictionary.rfc3576
$INCLUDE dictionary.rfc3580
以下略

我的NAS用的是Extreme network summit X450交換機,需要修改的字典文件為dictionary.extreme,如果你使用的是其他NAS可以修改相應的字典文件,或是自己創(chuàng)建一個字典文件也可以。
加入下面兩行定義
ATTRIBUTE       Extreme-Netlogin-Extended-Vlan          211     string
ATTRIBUTE       Extreme-Security-Profile                212     string

字典修改后,修改ldap.attrmap讓LDAP可以返回extreme認證用的字段。配置文件保存在/usr/local/etc/raddb/下

添加以下屬性
replyItem   Tunnel-Type                      radiusTunnelType
replyItem   Tunnel-Medium-Type              radiusTunnelMediumType
replyItem   Tunnel-Private-Group-Id           radiusTunnelPrivateGroupId
replyItem   Extreme-Security-Profile           radiusExtremeSecurityProfile
replyItem   Extreme-Netlogin-Vlan-Tag        radiusExtremeNetloginVlanTag
replyItem   Extreme-Netlogin-Extended-Vlan  radiusExtremeNetloginExtendedVlan
另外需要把NT-Password字段修改如下,如果你希望radius用戶使用samba的密碼,可以不用修改這部分,因為我希望密碼分開管理,而且網(wǎng)絡認證的密碼不會發(fā)給用戶,所以我用了其他的字段做為Freeradius的認證密碼。

checkItem       NT-Password                     radiusUserPassword

這部分再次說明一下,如果是用Winxp客戶端認證的話,一定要用MD4(WinNT)方式加密后再放到radiusUserPassword中

另外Windows通過Freeradius認證時,密碼通過MD4(WinNT)的方式加密,所以需要儲存在LDAP中的radiusUserPassword也通過MD4的加密方式保存,這樣才能通過認證。另外,通過ntradping驗證工具是不能驗證MD4是否成功的需要,通過WinXP客戶端進行驗證。

===========================分割線==========================

配置可使用的認證方式:
修改認證方式配置文件,目錄為/usr/local/etc/raddb/sites-available
兩個比較重要的文件
default    #默認配置文件
inner-tunnel   #認證虛擬機配置文件,這個文件我沒做仔細研究,如果有了解的朋友希望能交流一下

#vi default
用戶認證部分只保留了ldap和eap部分,其他的認證用不到我注釋掉了,如果你需要其他的認證去掉相應的注釋部分。
authorize {
        ldap
        eap
}

驗證部分保留了下面的選項,支持MS-CHAP驗證方式,LDAP驗證和EAP驗證
authenticate {
        Auth-Type MS-CHAP {
                mschap
        }
        ldap
        eap
}
authorize    配置用戶信息通過那種方式獲得,LDAP服務器、Mysql服務器、Unix系統(tǒng)帳號還是files文件。
authenticate 配置驗證方式,密碼的格式等等
除上述部分外未作任何修改。

===========================分割線==========================
配置eap認證方式:
修改內(nèi)容如下
#cat eap.conf|grep -v “#”
eap {
                default_eap_type = peap
                timer_expire     = 60
                ignore_unknown_eap_types = no
                tls {
                        certdir = ${confdir}/certs
                        cadir = ${confdir}/certs
                        private_key_password = cyberstep
                        private_key_file = ${certdir}/server.pem
                        certificate_file = ${certdir}/server.pem
                        CA_file = ${cadir}/ca.pem
                        dh_file = ${certdir}/dh
                        random_file = ${certdir}/random
                        fragment_size = 1024
                        include_length = yes
                        make_cert_command = "${certdir}/bootstrap"
                }
                peap {
                        default_eap_type = mschapv2
                }
                mschapv2 {
                }
        }
主要修改部分為交eap的默認認證方式改為peap,原為MD5,另外添加對tls的支持,希望客戶端和Freeradius通信時采用證書加密。另外將peap默認認證方式改為mschapv2。

Freeradius生成證書
Freeradius2.0.5含有證書制作腳本,只要OpenSSL的路徑正確,F(xiàn)reeradius可以自己制作證書,不過需要修改一下相關的信息,文件在/usr/local/etc/raddb/certs目錄下,需要修改的文件為ca.cnf server.cnf client.cnf
#more ca.cnf
default_days            = 3650
default_crl_days        = 3650
[certificate_authority]
countryName             = JP
stateOrProvinceName     = Tokyo
localityName            = Shibuya
organizationName        = Yepn Inc.
emailAddress            = zhou@yepn.net
commonName              = "yepn Certificate Authority"

其中比較重要的是這幾部分,days問題你也希望你的證書只能用一個月,或是一年的時間,相信網(wǎng)管都不喜歡這樣,所以我把時間設的長一點改成了10年。下面的certificate_authority是你證書的相關信息這個是方便查詢證書的出處,不清楚的地方請找OpenSSL的資料看一下,另外在cert文件夾中有Makefile文件,我也小修改了一下,不知道為什么前面對于ca.cnf日期的修改在cn.cnf中不生效,所以我只好把命令行那邊加上一個-days 3650
修改后如下
#more Makefile
openssl req -new -x509 -days 3650 -keyout ca.key -out ca.pem -config ./ca.cnf

因為OpenSSL自己也不是特別明白,所以沒辦法講的更細了,希望明白的朋友指點一下。

這樣生成后的ca.der證書可以導入到Winxp中。

到此為止Freeradius的配置就完成了,可以通過radiusd –Xf 測試一下radius的配置是否正確?梢酝ㄟ^radtest命令來驗證一下Freeradius能驗證。

===========================分割線==========================
OpenLDAP配置:
因為LDAP中加入了對radius屬性的支持,所以需要修改OpenLDAP配置文件。
復制raiuds.schema文件到openLDAP的schema目錄下
#cp /usr/local/share/doc/freeradius/examples/ openldap.schema /etc/openldap/schema/radius.schema

因為上面剛剛新加的幾個attribute的值在這個標準的radius.schema文件中沒有,所以需要自己定義幾個新的attribute的值
添加內(nèi)容如下:
attributetype
( 1.3.6.1.4.1.3317.4.3.1.61
NAME ‘radiusExtremeSecurityProfile’
DESC ‘’
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
)
attributetype
( 1.3.6.1.4.1.3317.4.3.1.62
NAME ‘radiusExtremeNetloginVlanTag’
DESC ‘’
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
)
attributetype
( 1.3.6.1.4.1.3317.4.3.1.63
NAME ‘radiusExtremeNetloginExtendedVlan’
DESC ‘’
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
)
attributetype
   ( 1.3.6.1.4.1.3317.4.3.1.66
      NAME 'radiusUserPassword'
      DESC 'radiusUserPassword'
      SUP userPassword
   )
OpenLDAP schema修改:
對于OpenLDAP schema的格式問題不在這里作更多說明,有很多文章解決如果編寫自己的schema文件請參閱。只在這里說明一點對于radiusUserPassword部分的定義,我讓radiusUserPassword繼承userPassword的特性,如果需要修改的朋友可以自己改成其他屬性。
最后,別忘記在你的objectclass里添加剛剛加的屬性

objectclass
   ( 1.3.6.1.4.1.3317.4.3.2.1
      NAME 'radiusprofile'
      SUP top AUXILIARY
      DESC ''
      MUST cn
      MAY ( radiusArapFeatures $ radiusArapSecurity $ radiusArapZoneAccess $
            radiusAuthType $ radiusCallbackId $ radiusCallbackNumber $
            radiusCalledStationId $ radiusCallingStationId $ radiusClass $
            radiusClientIPAddress $ radiusFilterId $ radiusFramedAppleTalkLink $
            radiusFramedAppleTalkNetwork $ radiusFramedAppleTalkZone $
            radiusFramedCompression $ radiusFramedIPAddress $
            radiusFramedIPNetmask $ radiusFramedIPXNetwork $
            radiusFramedMTU $ radiusFramedProtocol $
            radiusCheckItem $ radiusReplyItem $
            radiusFramedRoute $ radiusFramedRouting $ radiusIdleTimeout $
            radiusGroupName $ radiusHint $ radiusHuntgroupName $
            radiusLoginIPHost $ radiusLoginLATGroup $ radiusLoginLATNode $
            radiusLoginLATPort $ radiusLoginLATService $ radiusLoginService $
            radiusLoginTCPPort $ radiusLoginTime $ radiusPasswordRetry $
            radiusPortLimit $ radiusPrompt $ radiusProxyToRealm $
            radiusRealm $ radiusReplicateToRealm $ radiusServiceType $
            radiusSessionTimeout $ radiusStripUserName $
            radiusTerminationAction $ radiusTunnelClientEndpoint $
radiusProfileDn $
            radiusSimultaneousUse $ radiusTunnelAssignmentId $
            radiusTunnelMediumType $ radiusTunnelPassword $
radiusTunnelPreference $
            radiusTunnelPrivateGroupId $ radiusTunnelServerEndpoint $
            radiusTunnelType $ radiusUserCategory $ radiusVSA $
            radiusExpiration $ dialupAccess $ radiusNASIpAddress $
            radiusReplyMessage $ radiusExtremeSecurityProfile $
            radiusExtremeNetloginVlanTag $ radiusExtremeNetloginExtendedVlan $
            radiusUserPassword)
   )

看似很復雜,其實schema的說明很簡單,多找些資料看看會明白很多,我這里給出了全部的objectclass的值。

radius.schema文件修改后,別忘了修改slapd.conf配置文件加載radius.schema文件,讓OpenLDAP能識別這些新屬性。

加入以下內(nèi)容
include /etc/openldap/schema/radius.schema

重啟OpenLDAP
#service ldap restart

到這里OpenLDAP的配置就結束了,可以說Freeradius+OpenLDAP+PEAP認證的配置已經(jīng)完成了一大部分了,最后就是OpenLDAP數(shù)據(jù)的添加。

對于批量的OpenLDAP數(shù)據(jù)庫修改不放在這里,需要的朋友請到我的Wiki上查找,可以實現(xiàn)大批量的LDAP數(shù)據(jù)修改。

===========================分割線==========================

一個radius用戶的例子:
#cat zhou.ldif
dn: uid=zhou,ou=Users,dc=yepn,dc=net
add: objectClass
objectClass: radiusprofile
-
add: radiusSessionTimeout
radiusSessionTimeout: 43200
-
add: radiusTunnelType
radiusTunnelType: VLAN
-
add: radiusTunnelMediumType
radiusTunnelMediumType: IEEE-802
-
add: radiusTunnelPrivateGroupId
radiusTunnelPrivateGroupId: 160
-
add: radiusTerminationAction
radiusTerminationAction: RADIUS-Request
-
add: radiusExtremeSecurityProfile
-
add: radiusUserPassword
radiusUserPassword:  178DEACBFD994B3A6A67F49F420DB96A

格式要與我上面的相同,如果不一樣的話不能通過ldapmodify方式導入

#ldapmodify –x –D “cn=root,dc=yepn,dc=net” –w password –f zhou.ldif

把修改后的數(shù)據(jù)導入到LDAP中
#ldapsearch –x uid=zhou   
我的LDAP支持匿名查詢

===========================分割線==========================
以下為完整的zhou用戶信息
# extended LDIF
#
# LDAPv3
# base <> with scope subtree
# filter: uid=zhou
# requesting: ALL
#

# zhou, Users, yepn,net
dn: uid=zhou,ou=Users,dc=yepn,dc=com
sn: zhou
givenName: zhou
gecos: System User
sambaLogonTime: 0
sambaLogoffTime: 2147483647
displayName: zhou
sambaSID: S-1-5-21-1153389650-4125104348-4025214935-3060
sambaPrimaryGroupSID: S-1-5-21-1153389650-4125104348-4025214935-2001
sambaLogonScript: logon.bat
sambaProfilePath: \\PDC-SRV\profiles\zhou
sambaHomePath: \\PDC-SRV\zhou
sambaHomeDrive: H:
sambaPasswordHistory: 00000000000000000000000000000000000000000000000000000000
00000000
mail: zhou@yepn.com
shadowMax: 45
uid: zhou
cn: zhou
homeDirectory: /home/zhou
uidNumber: 1030
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
objectClass: sambaSamAccount
objectClass: radiusprofile
gidNumber: 500
shadowLastChange: 14027
loginShell: /bin/bash
radiusSessionTimeout: 43200
radiusTunnelType: VLAN
radiusTunnelMediumType: IEEE-802
radiusTerminationAction: RADIUS-Request
sambaDomainName: YEPN
radiusTunnelPrivateGroupId: 310
sambaAcctFlags: [XU         ]
sambaLMPassword: 44EFCE164AB921CAAAD3B435B51404EE
sambaNTPassword: 32ED87BDB5FDC5E9CBA88547376818D4
sambaPwdLastSet: 1216031836
radiusUserPassword: 3FA45A060BD2693AE4C05B601D05CA0C
userPassword:: e0NSWVBUfSQxJGNFb0N5Z2JqJHpnSXdkUmpaUzl1MkdVR0hsZ2s3YTE=

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

需要說明的一點,關于radiusUserPassword密碼為000000,通過mkntpwd加密成MD4(WinNT)格式的密碼放到LDAP中,修改密碼時也不能直接修改,需要通過mkntpwd生成新密碼后再添加到LDAP中。
mkntpwd可以在SF.net的網(wǎng)站上下載
#wget http://nchc.dl.sourceforge.net/s ... tils/mkntpwd.tar.gz
#mkdir mkntpwd
#tar –zxvf mkntpwd.tar.gz –C mkntpwd
#cd mkntpwd
#make
#./mkntpwd –N password
8846F7EAEE8FB117AD06BDD830B7586C

生成密碼MD4格式密碼

Summit X450的配置
#configure radius netlogin primary server 172.31.7.7 1812 client-ip 172.16.0.1 vr VR-Default
#configure radius netlogin primary shared-secret testing123

Summit交換機因為我也了解不多,所以沒辦法做更多的說明。

===========================分割線==========================

客戶端配置:
修改WinXP客戶端配置,網(wǎng)絡屬性中如下圖修改。我的系統(tǒng)是日文的所以找來了一份英文的圖片,按下圖修改就OK了。

這里貼圖比較麻煩~需要的朋友請下載我做好的PDF文檔

這里沒有使用CA證書,先測試一下能不能通過認證。

需要修改Select Authentication Method的Configure選項,把Automatically use my Windows logon name and password這里去掉。

祝你好運,希望能一次通過認證。

Freeradius+OpenLDAP+PEAP_Authenticate 點擊下載

[ 本帖最后由 gavinzhm 于 2008-7-17 11:45 編輯 ]

論壇徽章:
0
2 [報告]
發(fā)表于 2008-07-17 16:06 |只看該作者
挺不錯的.支持一下.

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
3 [報告]
發(fā)表于 2008-07-19 22:28 |只看該作者
恩,是不錯,最近正想試試freeradius呢

論壇徽章:
1
摩羯座
日期:2015-01-08 14:01:55
4 [報告]
發(fā)表于 2008-07-22 16:56 |只看該作者
這個要贊一下,收藏了,感謝樓主忠于分享的GPL精神!

論壇徽章:
0
5 [報告]
發(fā)表于 2008-07-22 23:25 |只看該作者
lz不錯

論壇徽章:
0
6 [報告]
發(fā)表于 2008-08-19 14:42 |只看該作者
看帖回帖是一種美德!感謝樓主的分享!

論壇徽章:
0
7 [報告]
發(fā)表于 2009-01-17 11:19 |只看該作者
好東西,謝謝樓主分享

論壇徽章:
0
8 [報告]
發(fā)表于 2009-01-20 09:13 |只看該作者
謝謝樓主!學習了,不過對ldap還是不太熟悉。⌒枰獙W習!

論壇徽章:
0
9 [報告]
發(fā)表于 2009-01-21 00:03 |只看該作者
一直覺得radius作復雜的辦公網(wǎng)絡管理是個比較好的選擇,頂一下!

論壇徽章:
0
10 [報告]
發(fā)表于 2013-08-25 18:05 |只看該作者
感謝gavin,本人之前的PPTP通過Radius驗證LDAP帳號,老是提示Told to do MS-CHAPv2 for xxx with NT-Password,看完此帖才明白MS-CHAP-V2使用MD4密碼,而userPassword不支持MD4密碼,故參照作者,在inetOrgPerson對象類中添加了屬性radiusUserPassword,并使用mkntpwd創(chuàng)建MD4密碼保存在此字段中,然后在ldap.attrmap中添加checkItem       NT-Password   radiusUserPassword,測試成功,感謝gavin~~
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP