RADIUS Server คืออะไร? สอนติดตั้ง FreeRADIUS สำหรับ WiFi Enterprise 802.1X 2026

AAA Concept — Authentication, Authorization, Accounting

AAA คือแนวคิดพื้นฐานในการจัดการความปลอดภัยของเครือข่าย ประกอบด้วย 3 ส่วนหลัก

ตัวอักษร ความหมาย คำถามที่ตอบ ตัวอย่าง
Authentication ยืนยันตัวตน คุณเป็นใคร? Username/Password, Certificate, OTP
Authorization สิทธิ์การเข้าถึง คุณทำอะไรได้บ้าง? VLAN Assignment, Bandwidth Limit, ACL
Accounting บันทึกการใช้งาน คุณทำอะไรไปแล้ว? Login Time, Data Usage, Session Duration

RADIUS Protocol คืออะไร?

RADIUS (Remote Authentication Dial-In User Service) คือ Protocol มาตรฐานที่ใช้ทำ AAA สำหรับ Network Access ใช้ Port 1812 (Authentication) และ 1813 (Accounting)

# RADIUS Flow:
#
# 1. User เชื่อมต่อ WiFi/Switch
# 2. Access Point/Switch (NAS) ส่ง Access-Request ไป RADIUS Server
# 3. RADIUS Server ตรวจสอบ Credentials
# 4. RADIUS Server ส่งกลับ:
#    - Access-Accept (ผ่าน) + Attributes (VLAN, Bandwidth etc.)
#    - Access-Reject (ไม่ผ่าน)
#    - Access-Challenge (ต้องการข้อมูลเพิ่ม เช่น OTP)
#
# Components:
# - Supplicant: Client (Laptop, Phone)
# - Authenticator (NAS): Access Point, Switch
# - Authentication Server: RADIUS Server (FreeRADIUS)
#
# User ←→ AP/Switch ←→ RADIUS Server ←→ User Database
# (Supplicant)  (NAS/Authenticator)  (Auth Server)  (LDAP/AD/File)

ติดตั้ง FreeRADIUS บน Ubuntu

# FreeRADIUS เป็น Open-Source RADIUS Server ที่นิยมที่สุด
# รองรับ EAP, LDAP, AD, MySQL, PostgreSQL, TOTP และอื่น ๆ

# ติดตั้ง:
sudo apt update
sudo apt install freeradius freeradius-utils freeradius-ldap -y

# ตรวจสอบ Version:
freeradius -v

# ทดสอบ Start (Debug Mode):
sudo freeradius -X
# → -X = Debug Mode, แสดง Log ทุกอย่าง
# → ดูว่า "Ready to process requests" = สำเร็จ

# Start เป็น Service:
sudo systemctl enable --now freeradius
sudo systemctl status freeradius

# ไฟล์ Config หลัก:
# /etc/freeradius/3.0/radiusd.conf     — Config หลัก
# /etc/freeradius/3.0/clients.conf     — กำหนด NAS Clients
# /etc/freeradius/3.0/users            — User Database (File-based)
# /etc/freeradius/3.0/mods-enabled/    — Modules ที่เปิดใช้
# /etc/freeradius/3.0/sites-enabled/   — Virtual Server Config

users File — กำหนด User

# /etc/freeradius/3.0/users
#
# Format:
# username  Auth-Type := method, Attribute = value
#           Reply-Attribute = value

# ตัวอย่าง User ง่าย ๆ:
bob     Cleartext-Password := "password123"
        Reply-Message := "Welcome, Bob!"

# User พร้อม VLAN Assignment:
alice   Cleartext-Password := "alicepass"
        Tunnel-Type = VLAN,
        Tunnel-Medium-Type = IEEE-802,
        Tunnel-Private-Group-Id = "10"

# User พร้อม Bandwidth Limit (Mikrotik):
charlie Cleartext-Password := "charliepass"
        Mikrotik-Rate-Limit = "2M/2M"

# User ที่ถูก Disable:
disabled_user Auth-Type := Reject
        Reply-Message := "Account Disabled"

# ทดสอบ User:
radtest bob password123 localhost 0 testing123
# → Access-Accept = สำเร็จ
# → Access-Reject = ผิด

clients.conf — กำหนด NAS Clients

# /etc/freeradius/3.0/clients.conf
#
# กำหนด Access Point / Switch ที่จะส่ง RADIUS Request มา

# Default (localhost สำหรับ Testing):
client localhost {
    ipaddr = 127.0.0.1
    secret = testing123
    require_message_authenticator = no
    nas_type = other
}

# เพิ่ม Access Point:
client ap-building-a {
    ipaddr = 192.168.1.10
    secret = MySecretKey2026!
    shortname = ap-building-a
    nas_type = other
}

# เพิ่ม Switch:
client core-switch {
    ipaddr = 192.168.1.1
    secret = SwitchRadius2026!
    shortname = core-switch
    nas_type = cisco
}

# เพิ่ม Network Range:
client office-network {
    ipaddr = 192.168.1.0/24
    secret = OfficeRadius2026!
    shortname = office-aps
    nas_type = other
}

# สำคัญ: secret ต้องตรงกับที่ตั้งใน AP/Switch
# ใช้ Secret ที่แข็งแรง (ยาว ผสมตัวเลข ตัวอักษร สัญลักษณ์)

EAP Configuration — PEAP และ EAP-TLS

# EAP (Extensible Authentication Protocol)
# ใช้สำหรับ WiFi 802.1X Enterprise
#
# EAP Methods ที่นิยม:
# - PEAP (Protected EAP): Username/Password ผ่าน TLS Tunnel
# - EAP-TLS: Certificate-based (ปลอดภัยที่สุด)
# - EAP-TTLS: คล้าย PEAP แต่ยืดหยุ่นกว่า

# /etc/freeradius/3.0/mods-enabled/eap
eap {
    default_eap_type = peap

    tls-config tls-common {
        private_key_file = /etc/freeradius/3.0/certs/server.key
        certificate_file = /etc/freeradius/3.0/certs/server.pem
        ca_file = /etc/freeradius/3.0/certs/ca.pem
        dh_file = /etc/freeradius/3.0/certs/dh
        ca_path = /etc/freeradius/3.0/certs
        tls_min_version = "1.2"
        tls_max_version = "1.3"
    }

    peap {
        tls = tls-common
        default_eap_type = mschapv2
        copy_request_to_tunnel = yes
        use_tunneled_reply = yes
    }

    tls {
        tls = tls-common
    }
}

# สร้าง Self-Signed Certificate (Testing):
cd /etc/freeradius/3.0/certs
sudo make
# → สร้าง ca.pem, server.pem, server.key

# Production: ใช้ Certificate จาก Internal CA หรือ Let's Encrypt

RADIUS + LDAP/AD Integration

# เชื่อมต่อ FreeRADIUS กับ Active Directory / LDAP
# เพื่อใช้ AD Account ในการ Authenticate

# 1. เปิด Module:
cd /etc/freeradius/3.0/mods-enabled
sudo ln -s ../mods-available/ldap ldap

# 2. แก้ไข /etc/freeradius/3.0/mods-enabled/ldap:
ldap {
    server = "ldap://dc01.company.local"
    port = 389
    identity = "CN=radius,OU=Service Accounts,DC=company,DC=local"
    password = "RadiusLDAPPass2026!"
    base_dn = "DC=company,DC=local"

    user {
        base_dn = "OU=Users,${..base_dn}"
        filter = "(sAMAccountName=%{%{Stripped-User-Name}:-%{User-Name}})"
    }

    group {
        base_dn = "OU=Groups,${..base_dn}"
        filter = "(objectClass=group)"
        membership_filter = "(|(member=%{control:Ldap-UserDn})(memberUid=%{%{Stripped-User-Name}:-%{User-Name}}))"
    }
}

# 3. แก้ไข sites-enabled/default:
# ในส่วน authorize:
authorize {
    ldap
    if (ok || updated) {
        update control {
            Auth-Type := ldap
        }
    }
}

# 4. Restart:
sudo systemctl restart freeradius

RADIUS สำหรับ WiFi 802.1X

# WiFi Enterprise (WPA2/WPA3-Enterprise) ใช้ 802.1X + RADIUS
#
# ขั้นตอนตั้งค่า:
#
# 1. RADIUS Server (FreeRADIUS):
#    - ตั้งค่า Users / LDAP
#    - ตั้งค่า EAP (PEAP)
#    - เพิ่ม AP ใน clients.conf
#
# 2. Access Point:
#    - เลือก Security: WPA2-Enterprise
#    - ใส่ RADIUS Server IP: 192.168.1.100
#    - ใส่ RADIUS Port: 1812
#    - ใส่ RADIUS Secret: (ตรงกับ clients.conf)
#
# 3. Client Device:
#    - เลือก Network → WPA2-Enterprise
#    - EAP Method: PEAP
#    - Phase 2: MSCHAPv2
#    - Identity: username
#    - Password: password
#    - CA Certificate: Trust (หรือ Import CA Cert)

# ตัวอย่าง Config บน Ubiquiti:
# Settings → WiFi → Security → WPA Enterprise
# RADIUS Server: 192.168.1.100
# Port: 1812
# Password: MySecretKey2026!

# ตัวอย่าง Config บน Mikrotik:
# /interface wireless security-profiles
# add name=radius-profile authentication-types=wpa2-eap
#     mode=dynamic-keys eap-methods=peap
#     radius-eap-accounting=yes
#     tls-mode=no-certificates

RADIUS สำหรับ Switch 802.1X

# Port-Based Authentication บน Switch
# อุปกรณ์ต้อง Authenticate ก่อนจะใช้ Port ได้

# Cisco Switch Config:
enable
configure terminal
aaa new-model
aaa authentication dot1x default group radius
aaa authorization network default group radius
aaa accounting dot1x default start-stop group radius

radius server FREERADIUS
 address ipv4 192.168.1.100 auth-port 1812 acct-port 1813
 key SwitchRadius2026!

dot1x system-auth-control

interface GigabitEthernet0/1
 switchport mode access
 switchport access vlan 10
 authentication port-control auto
 dot1x pae authenticator
 spanning-tree portfast

# HP/Aruba Switch Config:
radius-server host 192.168.1.100 key SwitchRadius2026!
aaa authentication port-access eap-radius
aaa port-access authenticator 1-24
 aaa port-access authenticator active

RADIUS สำหรับ VPN

# ใช้ RADIUS Authenticate VPN Users
#
# OpenVPN + RADIUS:
# ติดตั้ง Plugin:
sudo apt install openvpn-auth-radius -y

# /etc/openvpn/radiusplugin.cnf:
NAS-Identifier=OpenVPN-Server
Service-Type=5
Framed-Protocol=1
NAS-Port-Type=5
NAS-IP-Address=192.168.1.200
OpenVPNConfig=/etc/openvpn/server.conf

server {
    acctport=1813
    authport=1812
    name=192.168.1.100
    retry=1
    wait=1
    sharedsecret=VPNRadius2026!
}

# ใน server.conf เพิ่ม:
plugin /usr/lib/openvpn/radiusplugin.so /etc/openvpn/radiusplugin.cnf

# WireGuard + RADIUS:
# WireGuard ไม่ Support RADIUS โดยตรง
# ต้องใช้ Portal/API Server คั่นกลาง

Logging และ Accounting

# FreeRADIUS Accounting Log:
# /var/log/freeradius/radacct/ — Accounting Data

# เปิด Detailed Logging:
# /etc/freeradius/3.0/mods-enabled/detail
detail {
    filename = /var/log/freeradius/radacct/%{Client-IP-Address}/detail-%Y%m%d
    permissions = 0600
}

# Accounting Records ประกอบด้วย:
# - Acct-Status-Type: Start, Stop, Interim-Update
# - User-Name: ใครเชื่อมต่อ
# - NAS-IP-Address: เชื่อมต่อผ่านอุปกรณ์ไหน
# - Acct-Session-Time: ใช้เวลานานแค่ไหน (วินาที)
# - Acct-Input-Octets: Download เท่าไร (bytes)
# - Acct-Output-Octets: Upload เท่าไร (bytes)
# - Calling-Station-Id: MAC Address ของ Client
# - Called-Station-Id: MAC/SSID ของ AP

# SQL Accounting (เก็บใน Database):
# ติดตั้ง Module:
sudo apt install freeradius-mysql -y
# หรือ freeradius-postgresql

# เปิด Module:
cd /etc/freeradius/3.0/mods-enabled
sudo ln -s ../mods-available/sql sql

# แก้ไข sql module:
# dialect = "mysql"
# server = "localhost"
# login = "radius"
# password = "RadiusDB2026!"
# radius_db = "radius"

RADIUS vs TACACS+

คุณสมบัติ RADIUS TACACS+
Protocol UDP 1812/1813 TCP 49
Encryption เฉพาะ Password Encrypt ทั้ง Packet
AAA รวม Authentication + Authorization แยก AAA ออกจากกัน
ใช้สำหรับ Network Access (WiFi, VPN) Device Admin (Router, Switch)
Standard RFC 2865/2866 (Open) Cisco Proprietary (แต่มี Open Source)
Open Source FreeRADIUS tac_plus, TACACS+ daemon
Command Auth ไม่ได้ (ไม่เหมาะ) ได้ (ควบคุมคำสั่งที่ใช้ได้)
Multivendor ดีมาก (ทุก Vendor Support) จำกัด (Cisco เป็นหลัก)

NPS (Microsoft) — Alternative

# NPS (Network Policy Server) คือ RADIUS Server ของ Microsoft
# มาพร้อมกับ Windows Server
#
# ข้อดี:
# - Integrate กับ AD ง่าย (เป็น Microsoft ด้วยกัน)
# - GUI ใช้งานง่าย
# - Group Policy Integration
# - มี Wizard ช่วยตั้งค่า
#
# ข้อเสีย:
# - ต้องใช้ Windows Server License
# - Performance ต่ำกว่า FreeRADIUS
# - Customization จำกัดกว่า
# - ไม่ Open Source
#
# เหมาะกับ:
# - องค์กรที่ใช้ Windows Server อยู่แล้ว
# - IT Admin ที่ไม่ถนัด Linux
# - ต้องการ GUI
#
# FreeRADIUS เหมาะกับ:
# - องค์กรที่ใช้ Linux
# - ต้องการ Customization สูง
# - ISP / WISP
# - Cost-sensitive (ฟรี!)

Testing ด้วย radtest

# radtest เป็นเครื่องมือทดสอบ RADIUS ที่มากับ FreeRADIUS

# Syntax:
# radtest username password radius-server port shared-secret

# ทดสอบ Local:
radtest bob password123 localhost 0 testing123
# → Received Access-Accept = สำเร็จ
# → Received Access-Reject = ล้มเหลว

# ทดสอบ Remote:
radtest alice alicepass 192.168.1.100 0 MySecretKey2026!

# ทดสอบ EAP (PEAP):
# ใช้ eapol_test (จาก wpa_supplicant):
cat > eapol_test.conf << 'EOF'
network={
    ssid="TestSSID"
    key_mgmt=WPA-EAP
    eap=PEAP
    identity="bob"
    password="password123"
    phase2="auth=MSCHAPV2"
}
EOF
eapol_test -c eapol_test.conf -s testing123

# ทดสอบด้วย Verbose:
radtest -x bob password123 localhost 0 testing123
# -x = Extra debug output

# ทดสอบ Accounting:
echo "Acct-Status-Type=Start,User-Name=bob,Acct-Session-Id=12345" | radclient -x localhost:1813 acct testing123

สรุป: FreeRADIUS สำหรับ Enterprise Network

RADIUS Server โดยเฉพาะ FreeRADIUS เป็นเครื่องมือสำคัญสำหรับการจัดการ Network Access ในองค์กร ไม่ว่าจะเป็น WiFi Enterprise (802.1X), Switch Port Authentication, VPN Authentication หรือ ISP/WISP ที่ต้องจัดการ User หลายพันราย ความสามารถในการ Integrate กับ LDAP/AD, จัดการ VLAN Assignment, และเก็บ Accounting Data ทำให้ FreeRADIUS เป็นทางเลือกที่ดีที่สุดสำหรับ Open-Source RADIUS Solution ในปี 2026

.

.
.
.

จัดส่งรวดเร็วส่งด่วนทั่วประเทศ
รับประกันสินค้าเคลมง่าย มีใบรับประกัน
ผ่อนชำระได้บัตรเครดิต 0% สูงสุด 10 เดือน
สะสมแต้ม รับส่วนลดส่วนลดและคะแนนสะสม

© 2026 SiamLancard — จำหน่ายการ์ดแลน อุปกรณ์ Server และเครื่องพิมพ์ใบเสร็จ

SiamLancard
Logo
Free Forex EA — XM Signal · SiamCafe Blog · SiamLancard · Siam2R · iCafeFX
iCafeForex.com - สอนเทรด Forex | SiamCafe.net
Shopping cart