FreeRadius enable Virtual site with SQL

1. Create MySQL/ Postgresql Database and user

2. import FreeRadius database schema in

/usr/local/etc/raddb/mods-config/sql/main/mysql/schema.sql
/usr/local/etc/raddb/mods-config/sql/main/postgresql/schema.sql

3. edit sql configuration file and fill in database details

/usr/local/etc/raddb/mods-enabled/sql

	server = "hostname-here"
	port = 3306
	login = "database-login-here"
	password = "password-here"
	radius_db = "database-name-here"

4. if more than one database (for different application), copy the whole section, add an instance name and change the database details:

sql {

to

sql instance1

5. copy "default" configuration file to "virtual1" (or any name)

6. Edit "virtual1" file. and make the following changes

a) Change the virtual site name:

server default {

to

server virtual1

b) Change the port number

port = 55555

c) enable sql, 

find the following line

#      sql

and change to

instance1

"instance1" is the sql instance name added in step 4

7. Add a client for this virtual host

/usr/local/etc/raddb/clients.conf
client your-device {
       ipaddr = 192.168.0.0/24
       secret = secretPhrase
       virtual_server = virtual1
}

your-device is profile name

ipaddr is IP address (or IP address range) for your device(s). If more than 1, need to use "|" to separate

secret is the passphrase to use the radius service

virtual_server is the virtual site name used in step 5.

8. add user into the database

insert into radusergroup (username, groupname, priority) VALUES ('username','groupname', 1);
insert into radcheck (username, attribute, op, value) VALUES ('username', 'Cleartext-Password', ':=', 'password');

9. Restart radiusd