Install and Configure FreeRadius with MySQL

To complete my previous post about Creating Mikrotik User Manager, now I'd like to share a little information about installing FreeRadius with MySQL and how to configure it. And like the other post i have, i try to make it in the simple and fast way with example screenshot . My sample OS today is Fedora.

Install FreeRadius with MySQL
An easy way to install a new FreeRadius supported to our current Fedora is uisng YUM. Yum will resolve dependent software package related to FreeRadius, it's mean we don't need to find and download dependent package related to FreeRadius because yum will look for it, download and automatically install it.

[root@host ~]#yum -y install freeradius freeradius-mysql

If no problem occurs, then installation is complete.

Configuring FreeRadius with MySQL
All installed config file by default placed on "/etc/raddb", then change your directory to it.

[root@host ~]#cd /etc/raddb ;ls -altF

You should see many freeradius config dile there. Next is creating freeradius database (Assume you have already install MySQL).

[root@host raddb]# mysql -uroot -p
Enter password:
mysql>create database freeradius

Now that freeradius database successful created, we now may import freeradius tables from db_mysql.sql files. This file was placed in "/usr/share/doc/freeradius-(VERSION)/db_mysql.sql".

[root@host raddb]#mysql -u root -p freeradius < /usr/share/doc/freeradius-(VERSION)/db_mysql.sql

Database and tables for freeradius now created, next step is edit file sql.conf to setup MySQL server, login, password and database infomation.

[root@host raddb]#nano sql.conf

You don't need to edit anything on this file unless you know what you're doing, save it (Note you can use any text editor know like vi or vim). Next is edit clients.conf files to set radius secret key.

[root@host raddb]#nano clients.conf

secret = mysecretword

Now edit line "secret" with any secret word you want, then save when your done. Last is editing radius.conf config file. Look for "accounting {" and "authorize {" then remove "#" (comment) from "sql".

Save when you're done and all setting for freeradius is done. You may now start freeradius using "radiusd -y".

[root@host raddb]#radiusd -y

To get freeradius start on boot, type "ntsysv" and select radiusd using space to add radiusd to automatic start service.

Ok, let test our freeradius server. Create one account in freeradius database. Login to mysql and select freeradius database, then add username = test and password = password.

mysql> INSERT INTO radcheck (UserName, Attribute, Value) VALUES ('test', 'Password', 'password');
mysql> INSERT INTO radcheck (UserName, Attribute, Value) VALUES ('test', 'Auth-Type', 'Local');

Next is test our user with radtest.

[root@host raddb]#radtest test password localhost secret mysecretword

If "rad_recv: Access-Accept" showed up then your simple installation are complete now.