
RADIUS Authentication: ตั้งค่า FreeRADIUS สำหรับ WiFi Enterprise
RADIUS (Remote Authentication Dial-In User Service) เป็น protocol มาตรฐานสำหรับ authentication, authorization และ accounting (AAA) ใน network ใช้มากที่สุดสำหรับ WiFi Enterprise (WPA2/WPA3-Enterprise) ที่ผู้ใช้ login ด้วย username/password แทนที่จะใช้ shared password (PSK) เดียวกันทั้งองค์กร
FreeRADIUS เป็น RADIUS server open-source ที่นิยมที่สุดในโลก รองรับ 1 ใน 3 ของ RADIUS deployments ทั่วโลก ใช้โดยมหาวิทยาลัย ISPs และองค์กรขนาดใหญ่ ฟรี feature ครบ รองรับ EAP methods ทุกประเภท บทความนี้จะสอนวิธีติดตั้งและ configure FreeRADIUS สำหรับ WiFi Enterprise
ทำไมต้อง WiFi Enterprise (WPA2/WPA3-Enterprise)
| คุณสมบัติ | WPA2-Personal (PSK) | WPA2-Enterprise (RADIUS) |
|---|---|---|
| Authentication | Shared password เดียว | Username/password ต่อคน |
| เมื่อคนออก | ต้องเปลี่ยน password ทั้งองค์กร | ลบ account คนนั้นออก |
| Accountability | ไม่รู้ว่าใครเชื่อมต่อ | รู้ว่าใครเชื่อมต่อเมื่อไหร่ |
| Dynamic VLAN | ไม่ได้ | ได้ (assign VLAN ตาม user/group) |
| Encryption Key | ทุกคนใช้ key เดียวกัน | แต่ละ session มี key ต่างกัน |
| เหมาะกับ | บ้าน, ร้านกาแฟ | องค์กร, โรงเรียน, มหาวิทยาลัย |
RADIUS ทำงานอย่างไร
AAA Flow
Step 1: User เชื่อมต่อ WiFi → Access Point ส่ง authentication request ไป RADIUS server Step 2: RADIUS server ตรวจสอบ credentials (local database, LDAP, Active Directory) Step 3: ถ้าถูกต้อง RADIUS ส่ง Access-Accept กลับพร้อม attributes (VLAN, bandwidth policy) Step 4: AP อนุญาตให้ user เชื่อมต่อตาม attributes ที่ RADIUS กำหนด Step 5: RADIUS บันทึก accounting (เวลาเชื่อมต่อ, data usage)
ติดตั้ง FreeRADIUS
Installation บน Ubuntu
ติดตั้ง FreeRADIUS ด้วย apt install freeradius freeradius-utils ไฟล์ configuration หลักอยู่ที่ /etc/freeradius/3.0/ radiusd.conf: main configuration clients.conf: กำหนด RADIUS clients (APs, switches) users: กำหนด users (local authentication) sites-enabled/default: กำหนด authentication flow
Configure RADIUS Clients
clients.conf
กำหนด RADIUS clients คืออุปกรณ์ที่จะส่ง authentication request มาหา RADIUS server (Access Points, Switches) แต่ละ client ต้องกำหนด: IP address หรือ subnet, shared secret (password ระหว่าง client กับ RADIUS server) ตัวอย่าง: client AP_Floor1 { ipaddr = 10.0.10.100, secret = MySecretKey123 } ใช้ shared secret ที่ซับซ้อน (20+ characters, random)
Configure Users
Local Users
สำหรับ testing หรือองค์กรเล็ก กำหนด users ใน /etc/freeradius/3.0/users ตัวอย่าง: john Cleartext-Password := “P@ssw0rd123” Reply-Message := “Welcome John” กำหนด VLAN attributes: Tunnel-Type = VLAN, Tunnel-Medium-Type = IEEE-802, Tunnel-Private-Group-ID = “30” (VLAN 30 สำหรับ Staff)
LDAP/Active Directory Integration
สำหรับ องค์กรขนาดใหญ่ ใช้ LDAP module ของ FreeRADIUS เชื่อมต่อกับ Active Directory หรือ OpenLDAP users authenticate ด้วย AD credentials (username/password เดียวกับ login Windows) ไม่ต้อง maintain user database แยก configure ใน mods-enabled/ldap: server URL, base DN, bind credentials
EAP Methods
| EAP Method | ความปลอดภัย | ต้องการ Certificate | แนะนำ |
|---|---|---|---|
| PEAP (MSCHAPv2) | ดี | Server cert เท่านั้น | นิยมที่สุด ง่ายที่สุด |
| EAP-TLS | ดีที่สุด | Server + Client cert | ปลอดภัยสุด แต่ deploy cert ยาก |
| EAP-TTLS | ดี | Server cert เท่านั้น | ทางเลือกของ PEAP |
PEAP Configuration
PEAP เป็น EAP method ที่นิยมที่สุด ใช้ TLS tunnel ป้องกัน credentials ข้างในใช้ MSCHAPv2 สำหรับ authentication ต้องมี server certificate (ใช้ Let’s Encrypt หรือ self-signed) configure ใน mods-enabled/eap: default_eap_type = peap กำหนด certificate paths ใน eap.conf
Dynamic VLAN Assignment
วิธีทำงาน
RADIUS สามารถบอก AP ว่าให้ assign user เข้า VLAN ไหน ตาม user หรือ group ตัวอย่าง: ผู้บริหาร → VLAN 40 (Management), พนักงาน → VLAN 30 (Staff), แขก → VLAN 70 (Guest) AP ต้อง support dynamic VLAN (trunk port กับ switch ที่มี VLANs ทั้งหมด) ข้อดี: จัดการ VLAN ที่จุดเดียว (RADIUS server) ไม่ต้อง configure ที่ AP แต่ละตัว
ทดสอบ
radtest
ใช้ radtest ทดสอบ authentication: radtest john P@ssw0rd123 localhost 0 testing123 ถ้าได้ Access-Accept = สำเร็จ ถ้าได้ Access-Reject = credentials ผิดหรือ config ผิด ใช้ freeradius -X (debug mode) เพื่อดู detailed logs ของ authentication process
FreeRADIUS vs Alternatives
| RADIUS Server | ราคา | จุดเด่น | เหมาะกับ |
|---|---|---|---|
| FreeRADIUS | ฟรี | Feature ครบ flexible มาก | ทุกขนาดองค์กร |
| Microsoft NPS | มากับ Windows Server | AD integration ดีมาก | Windows AD environments |
| Cisco ISE | แพงมาก | Profiling, posture, TACACS+ | Large enterprise Cisco shops |
| Aruba ClearPass | แพง | Multi-vendor, guest portal | Large enterprise |
ทิ้งท้าย: WiFi Enterprise เป็น Must-Have สำหรับองค์กร
WiFi Enterprise + RADIUS ให้ security ดีกว่า PSK มาก ทุกคนมี credentials ส่วนตัว รู้ว่าใครเชื่อมต่อ assign VLAN ได้ตาม user FreeRADIUS เป็น RADIUS server ที่ดีที่สุดสำหรับเริ่มต้น ฟรี feature ครบ เริ่มจาก PEAP + local users แล้วค่อยเชื่อม AD
อ่านเพิ่มเติมเกี่ยวกับ 802.1X NAC และ WiFi 7 ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com