วันพุธที่ 5 สิงหาคม พ.ศ. 2552

Install Freeradius + Ldap server on Ubuntu 8.04.2 LTS

เนื่องจาก Pfsense มีส่วนของ Freeradius แต่ไม่มีส่วนที่สามารถ connect ldap ได้ จึงตั้ง Radius Server แยกออกมาต่างหาก เพื่อให้สามารถใช้ ldap authen ได้ โดย
1. ติดตั้ง Freeradius package โดย

root@radiusserver:~# aptitude install freeradius freeradius-ldap

2. เริ่มการทำงานของ freeradius โดย

root@radiusserver:~# /etc/init.d/freeradius start

3. ทดสอบการเชื่อมต่อโดย ใช้คำสั่ง radtest user password localhost port secret

root@radiusserver:~# radtest root mypassword localhost 0 testing123
Sending Access-Request of id 132 to 192.168.1.13 port 1812
User-Name = "root"
User-Password = "mypassword"
NAS-IP-Address = 255.255.255.255
NAS-Port = 0
Re-sending Access-Accept of id 132 to 192.168.1.13 port 1812

4. จากผลลัพธ์แสดงว่าสามารถใช้ฐานข้อมูล radius ได้แล้ว ต่อไปให้ทำการคอนฟิกให้สามารถ connect ldap จาก zimbra โดยแก้ไขไฟล์ /etc/freeradius/radiusd.conf

LDAP Configuration:
ldap {
server = "mail.company.co.th"
# identity = "cn=admin,o=My Org,c=UA"
# password = mypass
basedn = "dc=company,dc=co,dc=th"
filter = "(uid=%{Stripped-User-Name:-%{User-Name}})"
....
....
#access_attr = "dialupAccess"

# Authorization
authorize {
ldap //เอาคอมเมนต์ออก


# Authentication //เอาคอมเมนต์ออก 3 บรรทัด
authenticate {
Auth-Type LDAP {
ldap
}


5. แก้ไขไฟล์ /etc/freeradius/clients.conf

client 192.168.1.0/24 {
#
# The shared secret use to "encrypt" and "sign" packets between
# the NAS and FreeRADIUS. You MUST change this secret from the
# default, otherwise it's not a secret any more!
#
# The secret can be any string, up to 31 characters in length.
#
secret = mypassword

#
# The short name is used as an alias for the fully qualified
# domain name, or the IP address.
#
shortname = INTERNAL_SUBNET


6. แก้ไขไฟล์ /etc/freeradius/users


#DEFAULT Auth-Type = System
# Fall-Through = 1

DEFAULT Auth-Type = LDAP
Fall-Through = 1


7. ทดสอบใน debug mode โดย

root@radiusserver:~# /etc/init.d/freeradius stop
root@radiusserver:~# freeradius -X -A //เปิดทิ้งไว้เลยแล้วเปิดแท็บใหม่แล้วใช้ radtest ทดสอบว่าสามารถ authen ผ่าน ldap ได้หรือยัง
root@radiusserver:~# radtest anchalee password 192.168.1.13 0 mypassword
Sending Access-Request of id 44 to 192.168.1.13 port 1812
User-Name = "anchalee"
User-Password = "password"
NAS-IP-Address = 255.255.255.255
NAS-Port = 0
rad_recv: Access-Accept packet from host 192.168.1.13:1812, id=44, length=20 //แสดงว่าสามารถเชื่อมต่อผ่าน ldap ได้แล้ว ^-^

3 ความคิดเห็น:

pr_as@hotmail.com กล่าวว่า...

แสดงว่า ถ้า มีฐานข้อมูลผู้ใช้ที่เป็นของ ldap อยู่แล้วเนี่ย น่าจะเอามาใช้ได้เลย ไหม๊
หมายความว่า ระบบจะสามารถ ระบบตัวตนตั้งแต่ Authen เข้า ใช้งานเครื่อง เลยไหม๊

เนื่องจากที่ ที่หน่วยงาน มีการใช้งาน Domain Control ด้วย Ldap อยู่แล้ว

LinuxGirl~ กล่าวว่า...

สามารถนำ ldap ที่มีอยู่แล้วมาใช้งานได้เลยค่ะ โดยเปลี่ยนคอนฟิกไฟล์ให้ตรงกับ ldap ของเราแค่นี้ก็สามารถระบุตัวตนได้แล้วค่ะ ^-^

Unknown กล่าวว่า...

เซตค่า ยังไม่ได้ มันฟ้อง

radclient: no response from server for ID 81 socket 3

ท่านผู้รู้กรุณาช่วยหน่อยครับ