Adtive directory ม ส ทธ ต ดต งโปรแกรม

ค ม อการต ดต ง Radius server สาหร บบร การ eduroam บทนา ข นตอนการต ดต ง จะประกอบด วย 3 ข นตอนหล ก ก บ 2 ทางเล อก ประกอบด วย 1. การต ดต งและทดสอบพ นฐาน สามารถทาให Radius server ทางานได ด วยต วเอง ใช บ ญช ผ ใช ท ม อย ในไฟล ของโปรแกรม 2. การเล อกใช ฐานข อม ลบ ญช ผ ใช เป นการกาหนดให Radius server ใช บ ญช ผ ใช จากฐานข อม ลภายนอก ประกอบด วย 2 ทางเล อก - การต ดต งโดยม LDAP Server เป นฐานข อม ลบ ญช ผ ใช - การต ดต งโดยม Microsoft Active Directory เป นฐานข อม ลบ ญช ผ ใช 3. การต ดต งใช งานร วมก บ eduroam-th ว ธ การต ดต ง เป นการแนะนาคาส งในการด าเน นการอย างเป นลาด บ พร อมต วอย างคาส งท ตรงก บสภาพแวดล อมของ เคร องมากท ส ด เช น การต ดต งแพคเกจ การแก ไขไฟล การทดสอบการทางาน เป นต น โดยค ณสมบ ต ของโปรแกรม เก อบท งหมด เป นการนาไฟล สาเร จร ปท ผ านการปร บร ปแบบเพ อไม ให ซ าก บไฟล ค ณสมบ ต เด มของโปรแกรม นามา ต ดต ง ดาเน นการแก ไขเน อหาในไฟล ให เหมาะสม และใช งาน เพ อให การต ดต งม ความถ กต องและสามารถทางานได อย างไม ม ข อผ ดพลาด จาเป นต องด าเน นการตามลาด บข นโดย ละเอ ยด ยกเว นการเล อกใช ฐานข อม ลบ ญช ผ ใช ท สามารถเล อกได อย างใดอย างหน ง ห วข อ การตรวจว เคราะห และตรวจสอบการทางานของ Radius server เป นส วนของการแนะนาการปร บแต ง ค ณสมบ ต เพ อให Radius server ทางานท แตกต างหร อเพ มเต มจากการต ดต งน รวมถ งการตรวจสอบก จกรรมท เก ดข นท บ นท กไว ในไฟล Log ห วข อ การต ดต ง Wireless Controller หร อ Anonymous Access Point ร วมก บ Radius server แนะนาว ธ การ กาหนดค ณสมบ ต ของ Radius server และอ ปกรณ WLC หร อ AP ให ทางานร วมก น ล กษณะเด นของการกาหนดค ณสมบ ต ในการต ดต งน ค อ สามารถเป ดโอกาสให สมาช กภายในองค กรใช บร การเคร อข าย ภายในองค กรได ประโยชน ก เพ อให สมาช กดาเน นการกาหนดค ณสมบ ต การเช อมต อจากเคร อข ายภายในให สาเร จก อน แก ป ญหาให เสร จก อน จากน นจ งจะไปใช บร การจากผ ให บร การอ นได ท นท ร นของระบบปฏ บ ต การ และโปรแกรม freeradius ท ใช ทดลองต ดต ง คาส งและไฟล จะอ างอ งตามระบบปฏ บ ต การและโปรแกรม freeradius จ งควรเล อกใช ค าส งอย างถ กต อง ด งน - Debian 8.2 + freeradius-2.2.5 Radius version checking: freeradius -v 2016-06-18 16:30 -- 1/41

โครงสร างเคร อข ายประกอบการต ดต ง +--+ + Radius server +--+ [email protected] +--+ + LDAP server ldap.uxx.ac.th +--+ [email protected] or +--+ + Active Directory ad.uxx.local/uxx.local +--+ [email protected] or +--+ + MySQL radius:[email protected]/radius +--+ [email protected] +[ WLC or AP ] 2016-06-18 16:30 -- 2/41

การต ดต งและทดสอบข นพ นฐาน เป นการต ดต งและก าหนดค ณสมบ ต พ นฐานให Radius server สามารถทางานได ด วยต วเอง ประกอบด วยการต ดต ง โปรแกรม ต ดต งแพคเกจพ นฐาน ต ดต งแพคเกจสน บสน น ต ดต งโปรแกรมสาหร บทดสอบ แก ไขค ณสมบ ต พ นฐาน และ ทดสอบการทางาน โดยการทดสอบจะนาข อม ลผ ใช แบบไฟล ข อความท ม อย ไฟล user-eduroam.conf มาใช งาน 1. อ พเกรดแพคเกจล าส ดและแพคเกจพ นฐาน apt-get update apt-get upgrade -y อาจต อง reboot apt-get install ntp -y 2. ต ดต งแพคเกจ freeradius และแพคเกจสน บสน น apt-get install freeradius -y apt-get install easy-rsa -y apt-get install wget -y 3. ดาวน โหลดและคอมไพล เคร องม อสาหร บทดสอบ apt-get install gcc make libssl-dev -y cd /etc/freeradius wget http://www.rmuti.ac.th/user/prakai/p/freeradius-testtool.tar.gz tar vxfz freeradius-test-tool.tar.gz cd tool/wpa_supplicant-2.5/wpa_supplicant cp defconfig.config vi.config CONFIG_EAPOL_TEST=y CONFIG_DRIVER_NL80211=y make eapol_test cp eapol_test../../bin ref: http://deployingradius.com/scripts/eapol_test 4. ดาวน โหลดช ดไฟล ค ณสมบ ต สาเร จร ป cd /etc/freeradius wget http://www.rmuti.ac.th/user/prakai/p/freeradius-2- eduroam.tar.gz 2016-06-18 16:30 -- 3/41

5. แตกไฟล ค ณสมบ ต สาเร จร ป tar vxfz freeradius-2-eduroam.tar.gz ค ม อการต ดต ง Radius server สาหร บบร การ eduroam, ประกาย นาด, มทร.อ สาน รายการไฟล - radiusd-eduroam.conf ไฟล ค ณสมบ ต หล ก ใช ประกอบการแก ไขไฟล radiusd.conf - sites-available/eduroam ไฟล เร มต นสาหร บการเป ดใช ไซต eduroam - sites-available/eduroam-inner-tunnel ไฟล เร มต นสาหร บการเป ดใช ไซต eduroam-inner-tunnel - sites-available/eduroam-status ไฟล เร มต นสาหร บเป ดใช โมด ล radius status - clients-eduroam.conf ไฟล รายการเคร องล กข ายเพ อกาหนดให UniNet Radius เป น client ในกรณ การทาหน าท เป น IdP - proxy-eduroam.conf ไฟล ค ณสมบ ต เพ อกาหนดให UniNet Radius เป น home server ในกรณ การท าหน าท เป น SP - eap-eduroam.conf ไฟล ค ณสมบ ต การต งค าการท างานของ EAP - eduroam-realm-checks.conf สคร ปต การค ดกรองบ ญช ผ ดปกต ท ผ านการรวบรวมแล ว - modules/files-eduroam ไฟล โมด ลท ใช อ างถ งบ ญช ผ ใช จากไฟล ข อความ (user-eduroam) - users-eduroam ไฟล บ ญช ผ ใช แบบไฟล ข อความ สาหร บทดสอบโดยไม ต องใช บ ญช ผ ใช จากฐานข อม ล - modules/ldap-eduroam ไฟล โมด ลท ใช อ างถ งบ ญช ผ ใช จากฐานข อม ล LDAP - modules/mschap-eduroam ไฟล โมด ลท ใช อ างถ งบ ญช ผ ใช จากฐานข อม ล Active Directory - ldap.attrmap-eduroam - dictionary-eduroam - acct_users-eduroam - preproxy_users-eduroam 6. แก ไขไฟล radiusd.conf โดยปร บแก เฉพาะจ ดโดยเท ยบจากไฟล radiusd-eduroam.conf vi radiusd.conf Change some configurations in radiusd.conf as show below PROXY CONFIGURATION proxy_requests = yes $INCLUDE proxy.conf 2016-06-18 16:30 -- 4/41

eduroam $INCLUDE proxy-eduroam.conf CLIENTS CONFIGURATION $INCLUDE clients.conf eduroam $INCLUDE clients-eduroam.conf modules { Debian $INCLUDE ${confdir/modules/ Extensible Authentication Protocol For all EAP related authentications. Now in another file, because it is very large. $INCLUDE eap.conf eduroam $INCLUDE eap-eduroam.conf Include another file that has the SQL-related.. This is another file only because it tends to.. $INCLUDE sql.conf eduroaam $INCLUDE sql-eduroam.conf 7. แก ไขไฟล proxy-eduroam.conf โดยปร บแก เฉพาะจ ด vi proxy-eduroam.conf realm for local service realm uxx.ac.th { auth_pool = localhost 8. แก ไขไฟล sites- available/eduroam โดยปร บแก เฉพาะจ ด vi sites-available/eduroam authorize { Change realm to be LOCAL for local user if( ("%{Realm" =~ /uxx.ac.th$$/) ) { update control { 2016-06-18 16:30 -- 5/41

Proxy-To-Realm := LOCAL pre-proxy { Update Operator-Name to IdP update proxy-request { Operator-Name := "1uxx.ac.th" 9. ยกเล กไซต เด ม และเป ดใช ไซต ใหม cd sites-enabled rm -f default rm -f inner-tunnel ln -s../sites-available/eduroam ln -s../sites-available/eduroam-inner-tunnel ln -s../sites-available/eduroam-status cd.. 10. สร างไฟล Certificates cd certs rm * cp /usr/share/doc/freeradius/examples/certs/*. vi ca.cnf [ CA_default ] : default_days = 3650 : [certificate_authority] countryname = TH stateorprovincename = Bangkok localityname = - organizationname = University emailaddress = [email protected] commonname = "U Wi-Fi Certificate Authority" vi server.cnf [ CA_default ] : default_days = 3650 : [server] countryname = TH 2016-06-18 16:30 -- 6/41

stateorprovincename = Bangkok localityname = - organizationname = University emailaddress = [email protected] commonname = "U Wi-Fi Certificate" vi client.cnf [ CA_default ] : default_days = 3650 : [client] countryname = TH stateorprovincename = Bangkok localityname = - organizationname = University emailaddress = [email protected] commonname = [email protected]./bootstrap cd.. 11. เปล ยนส ทธ หร อเจ าของของไฟล chgrp -R freerad /etc/freeradius 12. ทดสอบการทางานแบบพ นฐาน หน าจอท 1 service freeradius stop freeradius -X (stop debuging with CTRL+C) หน าจอท 2 cd /etc/freeradius/tool./rad_eap_test -H 127.0.0.1 -P 1812 -S testing123 \ -u '[email protected]' -p 'TESTING-PASSWORD' -v \ -m IEEE8021X -s eduroam -e PEAP -2 MD5 access-accept; 0 RADIUS message: code=2 (Access-Accept) identifier=8 length=187 Attribute 27 (Session-Timeout) length=6 Value: 600 Attribute 1 (User-Name) length=21 Value: '[email protected]' Attribute 79 (EAP-Message) length=6 Value: 03080004 Attribute 80 (Message-Authenticator) length=18 Value: 6668fe5c30e59946dc91ad7200c0a810 2016-06-18 16:30 -- 7/41

การต ดต งโดยม LDAP Server เป นฐานข อม ลบ ญช ผ ใช เป นการต ดต งและก าหนดค ณสมบ ต พ นฐานให Radius server สามารถทางานก บ LDAP server (OpenLDAP) เพ อ ใช บ ญช ผ ใช จากฐานข อม ล LDAP ข อม ลบ ญช ผ ใช ควรม การเก บรห สผ านในร ปแบบ NT/LM Hash (NT-Password, LM-Password) การทางานของ Radius server จะต ดต อโดยตรงไปย ง LDAP server ผ านโมด ลท ม อย ใน Radius server 13. โครงสร างข อม ลใน LDAP Server โครงสร างหล กโดยย อของข อม ลผ ใช ใน LDAP Server dn: dc=uxx,dc=ac,dc=th objectclass: top objectclass: organization dc: u dn: ou=people,dc=uxx,dc=ac,dc=th ou: People objectclass: top objectclass: organizationalunit dn: ou=group,dc=uxx,dc=ac,dc=th ou: Group objectclass: top objectclass: organizationalunit dn: cn=users,ou=group,dc=uxx,dc=ac,dc=th cn: Users objectclass: posixgroup gidnumber: 1001 description: Group of Users on Unix System dn: uid=user,ou=people,dc=uxx,dc=ac,dc=th cn: User sn: User objectclass: top objectclass: posixaccount objectclass: shadowaccount objectclass: inetorgperson objectclass: sambasamaccount uid: user uidnumber: 1001 gidnumber: 1001 loginshell: /bin/bash homedirectory: /home/user gecos: User User description: User User displayname: User User sambaacctflags: [U ] sambalmpassword: C8DFD5AC0546E95DFF17365FAF1FFE89 sambantpassword: 2C47AA9B5AC02360473ECE87B6800920 sambasid:... 2016-06-18 16:30 -- 8/41

sambaprimarygroupsid:... userpassword:: e1ntsef9y0f1dxbvnurlbvfhakxxadfsu2vvthl5wi9nq1dlsxm= 14. ต ดต งแพคเกจ freeradius-ldap ต ดต ง module เสร ม เพ อให freeradius เข าถ งข อม ลจาก LDAP ได apt-get install freeradius-ldap -y 15. แก ไขไฟล sites-available/eduroam-inner-tunnel โดยปร บแก เฉพาะจ ด vi sites-available/eduroam-inner-tunnel authorize { group { Read the 'users-eduroam' file files-eduroam { return if match ok = return for LDAP ldap-eduroam { return if match ok = return for Active Directory mschap-eduroam { return if match ok = return for MySQL sql-eduroam { return if match ok = return authenticate { Auth-Type PAP { pap for LDAP and/or MySQL Auth-Type MS-CHAP { mschap for Active Directory Auth-Type MS-CHAP { mschap-eduroam 2016-06-18 16:30 -- 9/41

eap-eduroam 16. แก ไขไฟล modules/ldap-eduroam โดยปร บแก ท กจ ดให ถ กต อง ส มพ นธ ก บ LDAP server vi modules/ldap-eduroam ldap ldap-eduroam { server = "your-ldap-server-host" identity = "cn=admin,dc=uxx,dc=ac,dc=th" password = mypass basedn = "dc=uxx,dc=ac,dc=th " filter = "(uid=%{%{stripped-user-name:-%{user- Name)" base_filter = "(objectclass=radiusprofile)" access_attr = "dialaccess" password_attribute = userpassword password_attribute = sambantpassword 17. เปล ยนส ทธ หร อเจ าของของไฟล chgrp -R freerad /etc/freeradius 18. ทดสอบการทางานด วยผ ใช จาก LDAP Server หน าจอท 1 service freeradius stop freeradius -X (stop debuging with CTRL+C) หน าจอท 2 cd /etc/freeradius/tool./rad_eap_test -H 127.0.0.1 -P 1812 -S testing123 \ -u '[email protected]' -p 'Asdf1234' -v -m IEEE8021X \ -s eduroam -e PEAP -2 MSCHAPV2 access-accept; 0 RADIUS message: code=2 (Access-Accept) identifier=8 length=187 Attribute 27 (Session-Timeout) length=6 Value: 600 Attribute 1 (User-Name) length=21 2016-06-18 16:30 -- 10/41

Value: '[email protected]' Attribute 79 (EAP-Message) length=6 Value: 03080004 Attribute 80 (Message-Authenticator) length=18 Value: 4f334b7622ec20537163ac31c1926d84 2016-06-18 16:30 -- 11/41

การต ดต งโดยม Microsoft Active Directory เป นฐานข อม ลบ ญช ผ ใช เป นการต ดต งและก าหนดค ณสมบ ต พ นฐานให Radius server สามารถทางานร วมก บ Microsoft Active Directory เพ อตรวจสอบผ ใช จากบ ญช ผ ใช ใน Active Directory การทางานของ Radius server จะตรวจสอบต วตนของผ ใช ผ านโปรแกรมภายนอก ค อ samba หร อ winbind จ ง จาเป นต องกาหนดค ณสมบ ต ของ samba หร อ winbind ให สามารถต ดต อก บ Active Directory เส ยก อน 19. แก ไขไฟล /etc/resolv.conf โดยปร บแก เฉพาะจ ด vi /etc/resolv.conf nameserver <dc_server_address> nameserver <other_dns_server> 20. แก ไขไฟล /etc/hosts โดยปร บแก เฉพาะจ ด vi /etc/hosts <dc_server_address> ad.uxx.local ad.uxx.ac.th ad 21. ต ดต งแพคเกจสน บสน นเก ยวก บ samba, krb5 และ winbind apt-get install samba winbind krb5-user krb5-config -y Default Kerberos version 5 realm: UXX.LOCAL Kerberos servers for your realm: ad.uxx.local Administrative server for your Kerberos realm: ad.uxx.local ถ าไม พบหน าจอการต งค า สามารถกาหนดค ณสมบ ต อ กคร ง dpkg-reconfigure -plow krb5-config 22. แก ไขไฟล /etc/samba/smb.conf โดยปร บแก เฉพาะจ ด vi /etc/samba/smb.conf [global] workgroup = UXX security = ADS realm = UXX.LOCAL encrypt passwords = yes 2016-06-18 16:30 -- 12/41

client use spnego = yes idmap config *:backend = tdb idmap config *:range = 1000-9999 idmap config UXX:backend = ad idmap config UXX:schema_mode = rfc2307 idmap config UXX:range = 10000-99999 winbind nss info = rfc2307 winbind trusted domains only = no winbind use default domain = yes winbind enum users = yes winbind enum groups = yes winbind refresh tickets = yes 23. แก ไขไฟล /etc/krb5.conf โดยปร บแก เฉพาะจ ด vi /etc/krb5.conf [libdefaults] default_realm = UXX.LOCAL dns_lookup_realm = true dns_lookup_kdc = false forwardable = true [realms] UXX.LOCAL = { kdc = ad.uxx.local admin_server = ad.uxx.local [domain_realm].uxx.local = UXX.LOCAL uxx.local = UXX.LOCAL 24. ร สตาร ตโปรแกรม samba และ winbind /etc/init.d/samba restart /etc/init.d/winbind restart 25. Join เคร อง Radius server ไปเป นสมาช กของ Active Directory Domain net ads join -U Administrator Enter Administrator's password: <Administrator s password> Using short domain name UXX Joined 'YOUR-RADIUS-SERVER' to dns domain 'UXX.LOCAL' 2016-06-18 16:30 13/41

26. ร สตาร ตโปรแกรม samba และ winbind /etc/init.d/samba restart /etc/init.d/winbind restart ค ม อการต ดต ง Radius server สาหร บบร การ eduroam, ประกาย นาด, มทร.อ สาน 27. ทดสอบผลการ Join เคร อง Radius server ไปเป นสมาช กของ Active Directory Domain wbinfo -u administrator user and other users หากไม ได ผล โดยม นใจว า Active Directory ทางาน และไฟล ค ณสมบ ต ถ กต อง ให ดาเน นการซ าในข อ 25-26 28. ทดสอบใช บ ญช ผ ใช จาก Active Directory /usr/bin/ntlm_auth domain=uxx.local --username=user \ --password=asdf1234 NT_STATUS_OK: Success (0x0) 29. เพ มส ทธ ให ผ ใช ท ร นโพรเซส Radius server เข าในกล มของผ ใช ท ร นโปรเซส winbind chown root:winbindd_priv /var/lib/samba/winbindd_privileged usermod -a -G winbindd_priv freerad 30. แก ไขไฟล modules/mschap-eduroam โดยปร บแก เฉพาะจ ด cd /etc/freeradius vi modules/mschap-eduroam mschap mschap-eduroam { use_mppe = yes require_encryption = yes require_strong = yes with_ntdomain_hack = yes ntlm_auth = "/usr/bin/ntlm_auth --request-nt-key domain=uxx.local username=%{stripped-user-name challenge=%{mschap:challenge:-00 nt-response=%{mschap:nt- Response:-00" ntlm_auth_timeout = 10 2016-06-18 16:30 14/41

31. แก ไขไฟล sites-available/eduroam-inner-tunnel โดยปร บแก เฉพาะจ ด vi sites-available/eduroam-inner-tunnel authorize { ค ม อการต ดต ง Radius server สาหร บบร การ eduroam, ประกาย นาด, มทร.อ สาน group { Read the 'users-eduroam' file files-eduroam { return if match ok = return for LDAP ldap-eduroam { return if match ok = return for Active Directory mschap-eduroam { return if match ok = return for MySQL sql- eduroam { return if match ok = return authenticate { Auth-Type PAP { pap for LDAP and/or MySQL Auth-Type MS-CHAP { mschap for Active Directory Auth-Type MS-CHAP { mschap-eduroam eap-eduroam 2016-06-18 16:30 -- 15/41

32. เปล ยนส ทธ หร อเจ าของของไฟล chgrp -R freerad /etc/freeradius 33. ทดสอบการทางานด วยผ ใช จาก Active Directory หน าจอท 1 service freeradius stop freeradius -X (stop debuging with CTRL+C) หน าจอท 2 cd /etc/freeradius/tool ค ม อการต ดต ง Radius server สาหร บบร การ eduroam, ประกาย นาด, มทร.อ สาน./rad_eap_test -H 127.0.0.1 -P 1812 -S testing123 \ -u '[email protected]' -p 'Asdf1234' -v -m IEEE8021X \ -s eduroam -e PEAP -2 MSCHAPV2 access-accept; 0 RADIUS message: code=2 (Access-Accept) identifier=8 length=187 Attribute 27 (Session-Timeout) length=6 Value: 600 Attribute 1 (User-Name) length=21 Value: '[email protected]' Attribute 79 (EAP-Message) length=6 Value: 03080004 Attribute 80 (Message-Authenticator) length=18 Value: 4f334b7622ec20537163ac31c1926d84 2016-06-18 16:30 -- 16/41

การต ดต งโดยม MySQL เป นฐานข อม ลบ ญช ผ ใช เป นการต ดต งและก าหนดค ณสมบ ต พ นฐานให Radius server สามารถทางานโดยเข าถ งฐานข อม ลผ ใช ท เก บไว ใน เซ ร ฟเวอร MySQL ข อม ลบ ญช ผ ใช ท เก บในร ปแบบของฐานข อม ลน น สามารถม โครงสร างใดก ได ข นอย ก บมหาว ทยล ยออกแบบและ จ ดเก บ แต ในค ม อน จะอ างอ งร ปแบบการจ ดเก บข อม ลตามว ธ การพ นฐานของ freeradius-mysql 34. โครงสร างข อม ลใน MySQL Server องค ประกอบพ นฐานท ส ดของการจ ดเก บข อม ลบ ญช ผ ใช ตามร ปแบบของ freeradius-mysql น น ข อม ลผ ใช จะเก บไว ในตาราง ช อ radcheck ม ร ปแบบของข อม ลผ ใช ด งน mysql> select * from radcheck; ++--+----++--+ id username attribute op value ++--+----++--+ 1 user Cleartext-Password := Asdf1234 ++--+----++--+ mysql> select * from radcheck; ++--+-++------+ id username attribute op value ++--+-++------+ 1 user NT-Password := 2C47AA9B5AC02360473ECE87B6.. 2 user LM-Password := C8DFD5AC0546E95DFF17365FAF.. ++--+-++------+ 35. ต ดต งแพคเกจ freeradius-mysql ต ดต ง module เสร ม เพ อให freeradius เข าถ งข อม ลจาก MySQL ได apt-get install freeradius-mysql -y 36. แก ไขไฟล radiusd.conf โดยปร บแก เฉพาะจ ดโดยเท ยบจากไฟล radiusd-eduroam.conf cd /etc/freeradius vi radiusd.conf modules { Include another file that has the SQL-related.. This is another file only because it tends to.. $INCLUDE sql.conf eduroaam $INCLUDE sql-eduroam.conf 2016-06-18 16:30 -- 17/41

37. แก ไขไฟล sites-available/eduroam-inner-tunnel โดยปร บแก เฉพาะจ ด vi sites-available/eduroam-inner-tunnel authorize { ค ม อการต ดต ง Radius server สาหร บบร การ eduroam, ประกาย นาด, มทร.อ สาน group { Read the 'users-eduroam' file files-eduroam { return if match ok = return for LDAP ldap-eduroam { return if match ok = return for Active Directory mschap-eduroam { return if match ok = return for MySQL sql- eduroam { return if match ok = return authenticate { Auth-Type PAP { pap for LDAP and/or MySQL Auth-Type MS-CHAP { mschap for Active Directory Auth-Type MS-CHAP { mschap-eduroam eap-eduroam 2016-06-18 16:30 -- 18/41

38. แก ไขไฟล sql-eduroam.conf โดยปร บแก เฉพาะจ ด vi sql-eduroam.conf sql sql-eduroam { ค ม อการต ดต ง Radius server สาหร บบร การ eduroam, ประกาย นาด, มทร.อ สาน driver = "rlm_sql_${database" Connection info: server = "<mysql_server_host_address>" port = 3306 login = "radius" password = "radpass" 39. แก ไขไฟล sql/mysql/dialup-eduroam.conf โดยปร บแก เฉพาะจ ด vi sql/mysql/dialup-eduroam.conf Query config: Username Use Stripped-User-Name, if it's there. Else use User-Name, if it's there, Else use hard-coded string "DEFAULT" as the user name. sql_user_name = "%{%{Stripped-User-Name:-%{%{User-Name:- DEFAULT" sql_user_name = "%{User-Name" กรณ ม ฐานข อม ลบ ญช ผ ใช ท ไม เป นไปตามร ปแบบของ freeradius-mysql จาเป นต องแก ไขคาส ง SQL เพ อให เหมาะสมก บโครงสร างข อม ลน น vi sql/mysql/dialup-eduroam.conf Authorization Queries These queries compare the check items for the user in ${authcheck_table and setup the reply items in ${authreply_table. You can use any query/tables you want, but the return data for each row MUST be in the following order: 0. Row ID (currently unused) 1. UserName/GroupName 2. Item Attr Name 3. Item Attr Value 4. Item Attr Operation 2016-06-18 16:30 -- 19/41

authorize_check_query = "SELECT id, username, attribute,\ value, op \ FROM ${authcheck_table \ WHERE username = '%{SQL-User-Name' \ ORDER BY id" authorize_reply_query = "SELECT id, username, attribute,\ value, op \ FROM ${authcheck_table \ WHERE username = '%{SQL-User-Name' \ ORDER BY id" 40. ทดสอบการทางานด วยผ ใช จาก MySQL หน าจอท 1 service freeradius stop freeradius -X (stop debuging with CTRL+C) หน าจอท 2 cd /etc/freeradius/tool./rad_eap_test -H 127.0.0.1 -P 1812 -S testing123 \ -u '[email protected]' -p 'Asdf1234' -v -m IEEE8021X \ -s eduroam -e PEAP -2 MSCHAPV2 access-accept; 0 RADIUS message: code=2 (Access-Accept) identifier=8 length=187 Attribute 27 (Session-Timeout) length=6 Value: 600 Attribute 1 (User-Name) length=21 Value: '[email protected]' Attribute 79 (EAP-Message) length=6 Value: 03080004 Attribute 80 (Message-Authenticator) length=18 Value: 4f334b7622ec20537163ac31c1926d84 2016-06-18 16:30 -- 20/41

การต ดต งใช งานร วมก บ eduroam-th 41. แก ไขไฟล radiusd.conf โดยปร บแก เฉพาะจ ดโดยเท ยบจากไฟล radiusd-eduroam.conf cd /etc/freeradius vi radiusd.conf Change some configurations in radiusd.conf as show below PROXY CONFIGURATION proxy_requests = yes $INCLUDE proxy.conf eduroam $INCLUDE proxy-eduroam.conf CLIENTS CONFIGURATION $INCLUDE clients.conf eduroam $INCLUDE clients-eduroam.conf 42. แก ไขไฟล proxy-eduroam.conf โดยปร บแก เฉพาะจ ด vi proxy-eduroam.conf realm for local service realm uxx.ac.th { auth_pool = localhost home_server eduroam-nro-a { type = auth+acct ipaddr = 202.28.112.6 port = 1812 secret = XXXXXXXXXXXXXXXX src_ipaddr = xxx.xxx.xxx.xxx status_check = status-server require_message_authenticator = yes 43. แก ไขไฟล clients-eduroam.conf โดยปร บแก เฉพาะจ ด vi clients-eduroam.conf eduroam server (NRO) 2016-06-18 16:30 -- 21/41

client eduroam-nro-a { secret = XXXXXXXXXXXXXXXX ipaddr = 202.28.112.6 UniNet require_message_authenticator = no shortname = eduroam-nro virtual_server = eduroam 44. ทดสอบการทางานด วยผ ใช eduroam จาก IdP อ น หน าจอท 1 service freeradius stop freeradius -X (stop debuging with CTRL+C) หน าจอท 2 cd /etc/freeradius/tool./rad_eap_test -H 127.0.0.1 -P 1812 -S testing123 -u '[email protected]' -p 'Asdf1234' -v -m IEEE8021X -s eduroam -e PEAP -2 MSCHAPV2 access-accept; 0 RADIUS message: code=2 (Access-Accept) identifier=8 length=187 Attribute 27 (Session-Timeout) length=6 Value: 600 Attribute 1 (User-Name) length=21 Value: '[email protected]' Attribute 79 (EAP-Message) length=6 Value: 03080004 Attribute 80 (Message-Authenticator) length=18 Value: 4f334b7622ec20537163ac31c1926d84 2016-06-18 16:30 -- 22/41

การต ดต ง Wireless Controller หร อ Anonymous Access Point ร วมก บ Radius server Radius server: แก ไขไฟล clients.conf หร อ clients-eduroam.conf เพ ม IP address หร อเคร อข ายของ Anonymous Access Point vi clients.conf client <ip_or_network_of_access_point> { secret = testing123 shortname = my_access_point client 172.16.11.8 { secret = secret_for_172_16_11_8 shortname = ap_172_16_11_8 client 192.168.0.0/24 { secret = secret_for_net_192_168_0_0_24 shortname = ap_in_net_192_168_0_0_24 Cisco Wireless Controller 1. Add/Edit RADIUS profile SECURITY > AAA > RADIUS > Authentication > [New ] or Edit Server IP Address(Ipv4/Ipv6): <radius_server_ip_address> Shared Secret Format: ASCII Shared Secret: <secret_shared_with _radius_server> Confirm Shared Secret: <secret_shared_with _radius_server> Key Wrap: [ ] Port Number: 1812 Server Status: Enabled Network User: [/] Enable 2016-06-18 16:30 -- 23/41

SECURITY > AAA > RADIUS > Accounting > [New ] or Edit Server IP Address(Ipv4/Ipv6): <radius_server_ip_address> Shared Secret Format: ASCII Shared Secret: <secret_shared_with _radius_server> Confirm Shared Secret: <secret_shared_with _radius_server> Port Number: 1813 Server Status: Enabled Network User: [/] Enable 2016-06-18 16:30 -- 24/41

2. Add/Edit Wireless LAN profile WLANs > WLANs > WLANs > [Create new ] or Edit Type: [WLAN] Profile Name: <wlan_profile> SSID: <wlan_ssid> ค ม อการต ดต ง Radius server สาหร บบร การ eduroam, ประกาย นาด, มทร.อ สาน WLANs > WLANs > WLANs > [wlan_profile] > Security > Layer 2 Layer 2 Security: WPA+WPA2 WPA+WPA2 Parameters WPA Policy: [ ] WPA2 Policy-AES: [/] Authentication Key Management 802.1X: [/] Enable 2016-06-18 16:30 -- 25/41

WLANs > WLANs > WLANs > [wlan_profile] > Security > AAA Server Authentication Servers Accounting Servers [/] Enabled [/] Enabled Server 1 [auth_radius_ip:port] [acct_radius_ip:port] Radius Server Accounting Interim Update: [/] 2016-06-18 16:30 -- 26/41

Aruba Wireless Controller 1. Create Radius Server profile Configuration > Security > Authentication > Servers > RADIUS Server 2. Edit Radius Server profile Configuration > Security > Authentication > Servers > RADIUS Server > eduroam 3. Create Server Group profile Configuration > Security > Authentication > Servers > Server Group 2016-06-18 16:30 -- 27/41

4. Add RADIUS to Server Group profile Configuration > Security > Authentication > Servers > Server Group > eduroam 5. Create L2 Authentication profile Configuration > Security > Authentication > L2 Authentication > 802.1X Authenticaion Profiles 6. Edit L2 Authentication profile Configuration > Security > Authentication > L2 Authentication > 802.1X Authenticaion Profiles > eduroam 2016-06-18 16:30 -- 28/41

7. Create AAA Authentication profile Configuration > Security > Authentication > AAA Authentication 2016-06-18 16:30 -- 29/41

8. Modify Advanced Authentication Configuration > Security > Authentication > Advanced 9. Modify AP Configuration Configuration > Wireless > AP Configuration > AP Group 2016-06-18 16:30 -- 30/41

2016-06-18 16:30 -- 31/41

2016-06-18 16:30 -- 32/41

การตรวจว เคราะห และตรวจสอบการทางานของ Radius server การทางานของ Radius server น น จะม การร บข อม ลการร องขอการเข าถ ง (Access-Request) จากภายนอก และส ง ต อเป นลาด บข นการทางานตามลาด บท ประกาศไว ในไฟล ค ณสมบ ต โดยลาด บข นสาค ญจะอย ในไฟล ไซต ท ประกาศใช ประกอบด วยไฟล sites-enabled/eduroam และไฟล sites-enabled/eduroam-inner-tunnel เม อ Radius server ได ร บการร องขอ จะนาข อม ลการร องขอเข าไปประมวลผลตามข นตอนในไฟล sitesenabled/eduroam เป นไฟล แรก และอาจส งต อไปย งการประมวลผลภายในในไฟล sites-enabled/eduroaminner-tunnel หร อส งต อไปย ง Radius server เคร องถ ดไป 1. การเข ยนภาษา unlang ใช ใน Radius server ผ ใช สามารถเข ยนภาษา unlang เพ อประมวลผลข อม ลและต ดส นใจการทางานได เช น เช ยนเพ อการตรวจสอบ ร ปแบบบ ญช ผ ใช ให เหมาะสม หร อเป นไปตามกฎของการใช บร การ eduroam เป นต น ร ปแบบของภาษา unlang จะใกล เค ยงก บภาษา C สามารถเข ยนให ม การตรวจสอบค าหร อต วแปร กาหนดเส นทาง การทางานตามร ปแบบของภาษาโปรแกรม และกาหนดผลการทางาน สามารถเข ยนภาษา unlang ได ในส วนการ ประมวลข อม ล เช น authrize {, authenticate { เป นต น ต วแปรของภาษา unlang จะเป นต วแปรภายใน ไม สามารถประกาศข นเองได ต วแปรท เก ดข น จะข นก บ 3 ส วนค อ ส วนของการทางานของโมด ล จากการกาหนดเป น Attribute ในไฟล dictionary และส งท ล กข ายส งเข ามาขณะร อง ขอบร การ การกาหนดค าให ต วแปร ใช ใน section ช อ update ใน 3 ตาแหน ง control, request และ response ต วอย าง เช น update request { User-Name := "login_name" update control { Proxy-To-Realm := "LOCAL" update response { Operator-Name := "1abc.ac.th" การอ างถ งต วแปร ใช ร ปแบบ %{Variable-Name เช น ไม ต องดาเน นการใน section ใดๆ เช น if( "%{Realm" =~ /rmuti.ac.th$$/ ) { reject ต วกระทาในภาษา unlang ม เช นเด ยวก บโปรแกรมภาษา C แต ม ความย ดหย นกว า เช น การเปร ยบเท ยบ (!foo) Negation 2016-06-18 16:30 -- 33/41

(foo bar) (foo && bar) (foo == bar) (foo!= bar) (foo =~ bar) (foo!~ bar) (foo < bar) (foo > bar) Or And Equal Not equal Regular expression (match) Negate regular expression (not match) Less than More than การกาหนดค า foo = value Add the attribute to the list, if and only if an attribute of the same name is not already present in that list. foo := value Add the attribute to the list. If any attribute of the same name is already present in that list, its value is replaced with the value of the current attribute. foo += value Add the attribute to the tail of the list, even if attributes of the same name are already present in the list. When the right hand side of the expression resolves to multiple values, it means add all values to the tail of the list. ต วอย างต วแปรท ม กม การอ างถ ง สามารถด ได จากการร นโปรแกรมแบบ Debug เช น การร องขอ (Request) Received Access-Request Id 0 from 127.0.0.1:59868 to 127.0.0.1:1812 User-Name = '[email protected]' NAS-IP-Address = 127.0.0.1 Calling-Station-Id = '70-6F-6C-69-73-68' Framed-MTU = 1400 NAS-Port-Type = Wireless-802.11 การตอบกล บ (Response) Sending Access-Challenge Id 0 from 127.0.0.1:1812 to... EAP-Message = 0x010100061920 Message-Authenticator = 0x00000000000000000000000000000000 Sending Access-Accept Id 9 from 127.0.0.1:1812 to 127.0.0.1:59868 User-Name := '[email protected]' EAP-Message = 0x03090004 Message-Authenticator = 0x00000000000000000000000000000000 การกาหนดเส นทางการไหลของโปรแกรม สามารถใช การกระทาแบบเล อกทางพ นฐาน ค อ if else elseif ได เช น if( "%{Realm" =~ /rmuti.ac.th$$/ ) { update control { Proxy-To-Realm := LOCAL else { update request { Realm := "eduroam" 2016-06-18 16:30 -- 34/41

2. การค ดกรองบ ญช ผ ใช ท ไม เหมาะสม เพ อค ดกรองบ ญช ท ผ ดปกต จ าเป นต องเข ยนภาษา unlange เพ มเข าไปในไซต ต วอย างช อบ ญช ท ไม เหมาะสม ค อ บ ญช ท ไม ม realm หร อไม ม @xxxx หร อบ ญช ท เก ดจากการทางานโดยอ ตโนม ต ของบางระบบปฏ บ ต การ เช น 3gppnetwork.org เป นต น ในการต ดต งน ได ม การเข ยนภาษา unlang เพ อค ดกรองบ ญช ท ไม เหมาะสมตามท ได รวบรวมไว แล ว ไว ในไฟล eduroam-realm-checks.conf และได นาไฟล น ไปประกอบเป นส วนหน งของไฟล ไซต sites-enabled/eduroam authorize { $INCLUDE ${confdir/eduroam-realm-checks.conf 3. การกาหนดเคร อข ายให เหมาะสมก บผ ใช ท ต างก น หากต องการผ ใช ต างการถ กท าให เช อมต อเข าก บเคร อข ายท ต างก น สามารถทาได โดยการส งข อม ลหมายเลข VLAN จาก Radius server ไปย ง Wireless Controller (WLC) หร อ Access Point (AP) ได ท งน ท WLC หร อ AP จะต องประกาศ VLAN ด วยหมายเลขท ตรงก บท ตอบกล บโดย Radius server ต วอย างเช น ต องการแยกระหว าง อาจารย (User-Name: txxxxxx) ก บน กศ กษา (User-Name: sxxxxxx) ให ใช เคร อข ายท ต างก นด งผ งเคร อข าย + Teacher +-----+ +---+ VID:100 for Teachers.++. Radius server L2 device ====================== AP +---+ +---+ VID:200 for Students ++ + Student sites-enabled/eduroam post-auth { update reply { Tunnel-Type := "VLAN" Tunnel-Medium-Type := "IEEE-802" if( "%{User-Name" =~ /^t*/ ) { update reply { Tunnel-Private-Group-Id := 100 elseif( "%{User-Name" =~ /^s*/ ) { update reply { Tunnel-Private-Group-Id := 200 else { 2016-06-18 16:30 -- 35/41

4. การด ก จกรรมการทางานของโปรแกรมโดยละเอ ยด (Full debuging) การตรวจสอบการทางานของโปรแกรม Radius server ว าทางานอย างถ กต องหร อไม น น ว ธ ท ด ท ส ดค อการส งร น โปรแกรมแบบ full debuging โปรแกรมจะพ มพ ผลการท างาน หร อก จกรรมท เก ดข นโดยละเอ ยออกทางจอภาพ ใน เคร องหน งเคร องจะสามารถร นโปรแกรม Radius server ได เพ ยงหน งโปรแกรม ด งน น หากจะร นโปรแกรมแบบ full debuging จะต องป ดโปรแกรมเด มก อน และส นส ดด วยการพ มพ CTRL+C การดาเน นการเป นด งน service freeradius stop freeradius -X หร อการบ นท กผลการท างานไว ในไฟล freeradius -X > text.txt 5. การบ นท กก จกรรมใน Log ค ณสมบ ต เก ยวก บการบ นท กก จกรรมการทางานท กาหนดไว การต ดต งน ใช ไฟล โมด ลเด ม และม ตาแหน งการบ นท ก ตามค าด งเด มของ Radius server ประกอบด วย sites-enabled/eduroam authorize { get request from local user and NRO (as IdP and SP) config: ${configdir/(modules or mods-enabled)/detail.log log: ${logdir/radacct/<client_ip>/auth-detail-<date> auth_log accounting { accouting request from local user and NRO (as IdP and SP) config: ${configdir/(modules or mods-enabled)/detail log: ${logdir/radacct/<client_ip>/detail-<date> detail post-auth { get result after authentication process (as IdP) config: ${configdir/(modules or mods-enabled)/detail.log log: ${logdir/radacct/<client_ip>/reply-detail-<date> reply_log pre-proxy { process and forward request to NRO (as SP) config: ${configdir/(modules or mods-enabled)/detail.log log: ${logdir/radacct/<client_ip>/pre-proxy-detail-<date> pre_proxy_log post-proxy { get response from NRO (as SP) config: ${configdir/(modules or mods-enabled)/detail.log log: ${logdir/radacct/<client_ip>/post-proxy-detail-<date> post_proxy_log 2016-06-18 16:30 -- 36/41

ต วอย างเน อหาในไฟล auth-detail Fri Oct 23 22:39:14 2015 Packet-Type = Access-Request User-Name = "[email protected]" NAS-IP-Address = 127.0.0.1 Calling-Station-Id = "70-6F-6C-69-73-68" Stripped-User-Name = "eduroam" NAS-Port-Type = Wireless-802.11 Realm = "rmuti.ac.th" ต วอย างเน อหาในไฟล reply-detail Sat Oct 24 02:01:00 2015 Packet-Type = Access-Accept Session-Timeout = 600 User-Name = "[email protected]" ต วอย างเน อหาในไฟล pre-proxy-detail Sat Oct 24 00:05:49 2015 Packet-Type = Access-Request User-Name = "[email protected]" NAS-IP-Address = 127.0.0.1 Calling-Station-Id = "70-6F-6C-69-73-68" Realm = "eduroam" Proxy-State = 0x30 ต วอย างเน อหาในไฟล post-proxy-detail Mon Oct 26 15:33:43 2015 Packet-Type = Access-Accept Session-Timeout = 600 User-Name = "[email protected]" Proxy-State = 0x39 2016-06-18 16:30 -- 37/41

6. ลาด บการทางานของค ณสมบ ต กรณ ทาหน าท เป น IdP (Access-Request) Request from local user or NRO Invalid user format sites-enabled/eduroam Pass Access-Reject state to post-auth authorize { $INCLUDE ${confdir/eduroam-realm-checks.conf if( ("%{Realm" =~ /rmuti.ac.th$$/) ) { update control { Proxy-To-Realm := LOCAL User is local realm else { update request { Realm := "eduroam" update control { Proxy-To-Realm := "eduroam" eap-eduroam { ok = return Processing EAP-TLS and pass data to eduroam-inner-tunnel EAP-TLS data from eduroam sites-enabled/eduroam-inner-tunnel authorize { if ("%{request:user-name" =~ /^(.*)@(.*)/) { update request { Stripped-User-Name := "%{1" Realm := NULL update control { Proxy-To-Realm := LOCAL Force as local authenticate group { files-eduroam { Read the 'users-eduroam' file Not found ok = return in users-eduroam ldap-eduroam { for LDAP ok = return mschap-eduroam { for Active Directory ok = return eap-eduroam { Continue handle EAP-TLS User not found ok = return Pass Access- Reject to post-auth Query user and pass data to authenticate 2016-06-18 16:30 -- 38/41

User information from authorize authenticate { eap-eduroam Fail of challenged or verified password Pass Access-Reject state to post-auth Auth-Type PAP { Challenge and pap verify password Auth-Type MS-CHAP { for LDAP mschap Auth-Type MS-CHAP { for Active Directory mschap-eduroam Success of challenged and verified password Pass Access-Accept state to post-auth User not found: Access-Reject Fail of challenged or verified password: Access-Reject Access-Accept state from authenticate post-auth { update reply { User-Name := "%{request:user-name" update outer.reply { User-Name = "%{request:user-name" Pass Access-Accept state to outer post-auth Invalid user format: Access-Reject Success: Access-Accept sites-enabled/eduroam post-auth { Post-Auth-Type REJECT { attr_filter.access_reject Reply Access-Accept or Access-Reject to local user or NRO 2016-06-18 16:30 -- 39/41

7. ลาด บการทางานของค ณสมบ ต กรณ ทาหน าท เป น SP (Access-Request) Request from local user Invalid user format sites-enabled/eduroam authorize { $INCLUDE ${confdir/eduroam-realm-checks.conf if( ("%{Realm" =~ /rmuti.ac.th$$/) ) { update control { Proxy-To-Realm := LOCAL else { update request { Realm := "eduroam" update control { User is not Proxy-To-Realm := "eduroam" local realm pre-proxy { Update Operator-Name to IdP update proxy-request { Operator-Name := "1rmuti.ac.th" Pass Request to NRO Reply Access-Accept or Access-Reject from NRO post-proxy { post_proxy_log Reply Access-Accept or Access-Reject to user 2016-06-18 16:30 -- 40/41

อ างอ ง - https://www.eduroam.us/node/89 - http://confluence.diamond.ac.uk/display/paauth/using+active+directory+as+authentication+source - https://wiki.samba.org/index.php/setup_a_samba_ad_member_server - http://freeradius.org/radiusd/man/unlang.html - https://www.tobtu.com/lmntlm.php - 2016-06-18 16:30 -- 41/41

Active Directory ทําหน้าที่อะไร

Active Directory (AD) เป็นเทคโนโลยีของ Microsoft ที่ใช้ในการจัดการคอมพิวเตอร์และอุปกรณ์อื่น ๆ บนเครือข่าย ซึ่งเป็นระบบปฏิบัติการที่ ใช้งานได้ทั้งเซิร์ฟเวอร์ในระบบและบนอินเทอร์เน็ต

Active Directory มีกี่ประเภท

Containers คล้ำยกับโฟลเดอร์(Folder) โดยจะใช้เก็บ containers และ objects ต่ำงๆ ไว้ภำยใน โดย container ใน Active Directory จะมีอยู่ 3 ประเภท คือ 1. Domains, 2.Sites, 3. Organizational Units (OU) Site.

Active Directory สำคัญอย่างไรต่อองค์กร

ระบบ Active Directory เป็นเครื่องมือที่มีหน้าที่สำคัญในการยืนยันตัวตนทางสารสนเทศที่มีการใช้งานอย่างแพร่หลายสำหรับองค์กรขนาดใหญ่ที่มีการนำเทคโนโลยีสารสนเทศต่าง ๆ เข้ามาดำเนินกิจการ เนื่องจากระบบ Active Directory เป็นระบบที่ถูกออกแบบมาเพื่อการยืนยันตัวตนรวมถึงการจำกัดสิทธิ์เพื่อเข้าถึงระบบงานต่าง ๆ ภายในองค์กรโดยเฉพาะ

Ad มีประโยชน์อย่างไร

AD ทำหน้าที่จัดเก็บข้อมูลต่างๆใน network ขององค์กร ไม่ว่าจะเป็น user account เครื่อง computer ที่อยู่ในระบบ file server printer application ต่างๆ user ที่จะเข้าใจงานบริการ directory จำเป็นต้องผ่านกระบวนการพิสูจน์ตัวตนจาก server จึงจะสามารถเข้าใช้บริการได้ เป็นการควบคุมความปลอดภัยของข้อมูล สามารถยืดหยุ่นและกำหนดสิทธิ์ ...