因為工作的關係,會接觸到Radius。

而身為一個不專業的IT,當然要以open source軟體為主。

所以就挑選最流行的radius軟體:FreeRadius

此次是安裝在Ubuntu 16.04並搭配Mysql。

在安裝前請先將系統更新至最新,並以root進行安裝(懶惰ing)。

基本上程式碼中的註解是直接從小弟做的sop直接複製過來的,就不做刪減了。(再次懶惰ing..)

    #Install LAMP server & setting mysql password
    sudo su
    apt-get update && apt-get upgrade

接著就要開始進行安裝。

    #install lamp-server
    apt-get install lamp-server^

    #install radius package
    apt-get install php-common php-gd php-pear php-db libapache2-mod-php php-mail
    apt-get install freeradius freeradius-mysql freeradius-utils

資料庫部分處理

    #create radius database
    mysql -u root -p
    create database radius;
    grant all on radius.* to radius@localhost identified by "password";

    #import temp table to db radius
    mysql -u root -p radius < /etc/freeradius/sql/mysql/schema.sql
    mysql -u root -p radius < /etc/freeradius/sql/mysql/nas.sql

    #create new user(client) to radius db
    mysql -u root -p
    use radius 
    INSERT INTO radcheck (UserName, Attribute, Value) VALUES (‘sqltest', ‘Password', ‘testpwd');

設定檔

    #edit conf for radius 
    vim /etc/freeradius/sql.conf
    ###change database, login, password & uncomment 'readclients = yes'

    vim /etc/freeradius/sites-enabled/default
    ###momment line 170, unmomment line 177, 406, 454, 476

    vim /etc/freeradius/radiusd.conf
    ###uncomment '$INCLUDE sql.conf'

最後來到了測試階段

在Radius Server上下

    #run freeradius debug mode first time, if don't have any err, press ctrl+c to quit debug mode
    /etc/init.d/freeradius stop
    freetadius -X
    /etc/init.d/freeradius start

並且開另外一個terminal去下指令測試

    #use command to test login to radius server
    radtest sqltest testpwd localhost 18128 testing123

如果測試結果出現了下方的Access-Accept訊息,表示建制完成囉,不過這僅僅是基本的FreeRadius Server,Radius可以做到超多進階的服務,就待有興趣的各位自行鑽研囉。

    #if response 'rad_recv: Access-Accept packet from host xxx.xxx.xxx.xxx port 1812, id=164, length=20' congraz, Ur auth was pass.
    #if not, U can change folder and watch /var/log/freeradius/radiusd.log to check message