Freeradius + MySQL (Step 1)

Based on Ubuntu 20.04 box with virtualmin installed, apache, php7.4

Install Freeradius

apt-get update
apt-get install freeradius freeradius-mysql freeradius-utils -y

Create FR database schema

mysql -uroot -pPasswordForRootSql
CREATE DATABASE radius;
exit

cd /etc/freeradius/3.0/mods-config/sql/main/mysql/
 
mysql -uroot -pYourMysqlPass radius < schema.sql
mysql -uroot -pYourMysqlpass radius < setup.sql

Set FR to using MySQL

cd /etc/freeradius/3.0/mods-enabled
ln -s ../mods-available/sql sql

Open “default” config using text editor

cd /etc/freeradius/3.0/sites-available/
vim default

Add sql on every category

authorize {
.....
sql
....
}
accounting {
......
sql
....
}
post-auth {
......
sql
....
}
session{
......
sql
.....}

Edit radius sql module’s config

cd /etc/freeradius/3.0/mods-available
vim sql

Modif following

driver = "rlm_sql_mysql"

dialect = "mysql"

 server = "localhost"
 port = 3306
 login = "root"
 password = "YOURMYSQLPASSWORD FROM STEP 4"
 radius_db = "radius"
read_clients = yes

Fill nas table from freeradius database with shortname (refer to ip address), shortname (server identify, ex. mikrotik), type (fill with other for mikrotik), secret (secret key), description (description).

Running FR debug mode

freeradius -X