Configure FreeRADIUS to use MySQL installed by HomeBrew
Hao Fu
h.fu at orb-connect.com
Wed Dec 4 15:18:41 UTC 2024
Hello. I'm new to FreeRADIUS. I am configuring FreeRADIUS to use the database in MySQL instead of the text files, so it's easier to manage.
I installed FreeRADIUS by Homebrew using "brew install freeradius-server". The Current version is 3.2.6_2. I tested it using radtest and got the "Access-Accept".
The MySQL is also installed by Homebrew using "brew install MySQL". The current version is 9.0.1. I created the database "radius" and the default schema for it.
Then I modified the radiusd.conf and mods-available/sql files to connect to the MySQL server as suggested in guide/SQL HOWTO: Configuring FreeRADIUS to use SQL. I didn't change anything in sites-available/default and inner-tunnel as the lines containing 'sql' are already uncommented (although they are in the form of '-sql').
Trying to fire up the server by "radius -X" got me this error:
radiusd -X
FreeRADIUS Version 3.2.6
Copyright (C) 1999-2023 The FreeRADIUS server project and contributors
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE
You may redistribute copies of FreeRADIUS under the terms of the
GNU General Public License
For more information about these matters, see the file named COPYRIGHT
Starting - reading configuration files ...
including dictionary file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/share/freeradius/dictionary
including dictionary file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/share/freeradius/dictionary.dhcp
including dictionary file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/share/freeradius/dictionary.vqp
including dictionary file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/dictionary
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/radiusd.conf
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/proxy.conf
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/clients.conf
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-available/sql
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-config/sql/main/mysql/queries.conf
including files in directory /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/detail.log
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/eap
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/echo
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/utf8
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/always
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/digest
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/date
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/preprocess
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/pap
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/expr
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/radutmp
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/linelog
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/unix
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/detail
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/attr_filter
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/ntlm_auth
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/exec
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/files
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/replicate
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/chap
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/unpack
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/logintime
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/expiration
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/soh
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/totp
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/sradutmp
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/mschap
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/dynamic_clients
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/passwd
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-enabled/realm
including files in directory /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/accounting
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/eap
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/rfc7542
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/canonicalization
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/abfab-tr
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/dhcp
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/cui
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/filter
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/moonshot-targeted-ids
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/operator-name
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/control
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/policy.d/debug
including files in directory /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/sites-enabled/
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/sites-enabled/default
including configuration file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/sites-enabled/inner-tunnel
main {
name = "radiusd"
prefix = "/opt/homebrew/Cellar/freeradius-server/3.2.6_2"
localstatedir = "/opt/homebrew/var"
sbindir = "/opt/homebrew/Cellar/freeradius-server/3.2.6_2/bin"
logdir = "/opt/homebrew/var/log/radius"
run_dir = "/opt/homebrew/var/run/radiusd"
libdir = "/opt/homebrew/Cellar/freeradius-server/3.2.6_2/lib"
radacctdir = "/opt/homebrew/var/log/radius/radacct"
hostname_lookups = no
max_request_time = 30
proxy_dedup_window = 1
cleanup_delay = 5
max_requests = 16384
postauth_client_lost = no
pidfile = "/opt/homebrew/var/run/radiusd/radiusd.pid"
checkrad = "/opt/homebrew/Cellar/freeradius-server/3.2.6_2/bin/checkrad"
debug_level = 0
proxy_requests = yes
log {
stripped_names = no
auth = no
auth_badpass = no
auth_goodpass = no
colourise = yes
msg_denied = "You are already logged in - access denied"
}
resources {
}
security {
max_attributes = 200
reject_delay = 1.000000
status_server = yes
require_message_authenticator = "auto"
limit_proxy_state = "auto"
allow_vulnerable_openssl = "no"
}
}
radiusd: #### Loading Realms and Home Servers ####
proxy server {
retry_delay = 5
retry_count = 3
default_fallback = no
dead_time = 120
wake_all_if_all_dead = no
}
home_server localhost {
nonblock = no
ipaddr = 127.0.0.1
port = 1812
type = "auth"
secret = <<< secret >>>
response_window = 20.000000
response_timeouts = 1
max_outstanding = 65536
zombie_period = 40
status_check = "status-server"
ping_interval = 30
check_interval = 30
check_timeout = 4
num_answers_to_alive = 3
revive_interval = 120
limit {
max_connections = 16
max_requests = 0
lifetime = 0
idle_timeout = 0
}
coa {
irt = 2
mrt = 16
mrc = 5
mrd = 30
}
}
home_server_pool my_auth_failover {
type = fail-over
home_server = localhost
}
realm example.com {
auth_pool = my_auth_failover
}
realm LOCAL {
}
radiusd: #### Loading Clients ####
client localhost {
ipaddr = 127.0.0.1
secret = <<< secret >>>
nas_type = "other"
proto = "*"
limit {
max_connections = 16
lifetime = 0
idle_timeout = 30
}
}
Shared secret for client localhost is short, and likely can be broken by an attacker.
client localhost_ipv6 {
ipv6addr = ::1
secret = <<< secret >>>
limit {
max_connections = 16
lifetime = 0
idle_timeout = 30
}
}
Shared secret for client localhost_ipv6 is short, and likely can be broken by an attacker.
Found debugger attached
# Creating Auth-Type = mschap
# Creating Auth-Type = digest
# Creating Auth-Type = eap
# Creating Auth-Type = PAP
# Creating Auth-Type = CHAP
# Creating Auth-Type = MS-CHAP
# Creating Autz-Type = New-TLS-Connection
radiusd: #### Instantiating modules ####
modules {
# Loaded module rlm_sql
# Loading module "sql" from file /opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-available/sql
sql {
driver = "rlm_sql_mysql"
server = "localhost"
port = 3306
login = "radius"
password = <<< secret >>>
radius_db = "radius"
read_groups = yes
read_profiles = yes
read_clients = no
delete_stale_sessions = yes
sql_user_name = "%{User-Name}"
default_user_profile = ""
client_query = "SELECT id, nasname, shortname, type, secret, server FROM nas"
authorize_check_query = "SELECT id, username, attribute, value, op FROM radcheck WHERE username = '%{SQL-User-Name}' ORDER BY id"
authorize_reply_query = "SELECT id, username, attribute, value, op FROM radreply WHERE username = '%{SQL-User-Name}' ORDER BY id"
authorize_group_check_query = "SELECT id, groupname, attribute, Value, op FROM radgroupcheck WHERE groupname = '%{SQL-Group}' ORDER BY id"
authorize_group_reply_query = "SELECT id, groupname, attribute, value, op FROM radgroupreply WHERE groupname = '%{SQL-Group}' ORDER BY id"
group_membership_query = "SELECT groupname FROM radusergroup WHERE username = '%{SQL-User-Name}' ORDER BY priority"
simul_count_query = "SELECT COUNT(*) FROM radacct a LEFT OUTER JOIN nasreload n USING (nasipaddress) WHERE username = '%{SQL-User-Name}' AND acctstoptime IS NULL AND (a.acctstarttime > n.reloadtime OR n.reloadtime IS NULL)"
simul_verify_query = "SELECT radacctid, acctsessionid, username, nasipaddress, nasportid, framedipaddress, callingstationid, framedprotocol FROM radacct a LEFT OUTER JOIN nasreload n USING (nasipaddress) WHERE username = '%{SQL-User-Name}' AND acctstoptime IS NULL AND (a.acctstarttime > n.reloadtime OR n.reloadtime IS NULL)"
safe_characters = "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /"
auto_escape = no
accounting {
reference = "%{tolower:type.%{%{Acct-Status-Type}:-%{Request-Processing-Stage}}.query}"
type {
accounting-on {
query = "UPDATE radacct SET acctstoptime = FROM_UNIXTIME(%{%{integer:Event-Timestamp}:-%l}), acctsessiontime = '%{%{integer:Event-Timestamp}:-%l}' - UNIX_TIMESTAMP(acctstarttime), acctterminatecause = '%{%{Acct-Terminate-Cause}:-NAS-Reboot}' WHERE acctstoptime IS NULL AND nasipaddress = '%{NAS-IP-Address}' AND acctstarttime <= FROM_UNIXTIME(%{%{integer:Event-Timestamp}:-%l})"
}
accounting-off {
query = "UPDATE radacct SET acctstoptime = FROM_UNIXTIME(%{%{integer:Event-Timestamp}:-%l}), acctsessiontime = '%{%{integer:Event-Timestamp}:-%l}' - UNIX_TIMESTAMP(acctstarttime), acctterminatecause = '%{%{Acct-Terminate-Cause}:-NAS-Reboot}' WHERE acctstoptime IS NULL AND nasipaddress = '%{NAS-IP-Address}' AND acctstarttime <= FROM_UNIXTIME(%{%{integer:Event-Timestamp}:-%l})"
}
start {
query = "INSERT INTO radacct (acctsessionid, acctuniqueid, username, realm, nasipaddress, nasportid, nasporttype, acctstarttime, acctupdatetime, acctstoptime, acctsessiontime, acctauthentic, connectinfo_startconnectinfo_stop, acctinputoctets, acctoutputoctets, calledstationid, callingstationid, acctterminatecause, servicetype, framedprotocol, framedipaddress, framedipv6address, framedipv6prefix, framedinterfaceid, delegatedipv6prefix ) VALUES ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{%{NAS-Port-ID}:-%{NAS-Port}}', '%{NAS-Port-Type}', FROM_UNIXTIME(%{%{integer:Event-Timestamp}:-%l}), FROM_UNIXTIME(%{%{integer:Event-Timestamp}:-%l}), NULL, '0', '%{Acct-Authentic}', '%{Connect-Info}', '', '0', '0', '%{Called-Station-Id}', '%{Calling-Station-Id}', '', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '%{Framed-IPv6-Address}', '%{Framed-IPv6-Prefix}', '%{Framed-Interface-Id}', '%{Delegated-IPv6-Prefix}' )"
}
interim-update {
query = "UPDATE radacct SET acctupdatetime = (@acctupdatetime_old:=acctupdatetime), acctupdatetime = FROM_UNIXTIME(%{%{integer:Event-Timestamp}:-%l}), acctinterval = %{%{integer:Event-Timestamp}:-%l} - UNIX_TIMESTAMP(@acctupdatetime_old), framedipaddress = '%{Framed-IP-Address}', framedipv6address = '%{Framed-IPv6-Address}', framedipv6prefix = '%{Framed-IPv6-Prefix}', framedinterfaceid = '%{Framed-Interface-Id}', delegatedipv6prefix = '%{Delegated-IPv6-Prefix}', acctsessiontime = %{%{Acct-Session-Time}:-NULL}, acctinputoctets = '%{%{Acct-Input-Gigawords}:-0}' << 32 | '%{%{Acct-Input-Octets}:-0}', acctoutputoctets = '%{%{Acct-Output-Gigawords}:-0}' << 32 | '%{%{Acct-Output-Octets}:-0}' WHERE AcctUniqueId = '%{Acct-Unique-Session-Id}'"
}
stop {
query = "UPDATE radacct SET acctstoptime = FROM_UNIXTIME(%{%{integer:Event-Timestamp}:-%l}), acctsessiontime = %{%{Acct-Session-Time}:-NULL}, acctinputoctets = '%{%{Acct-Input-Gigawords}:-0}' << 32 | '%{%{Acct-Input-Octets}:-0}', acctoutputoctets = '%{%{Acct-Output-Gigawords}:-0}' << 32 | '%{%{Acct-Output-Octets}:-0}', acctterminatecause = '%{Acct-Terminate-Cause}', connectinfo_stop = '%{Connect-Info}' WHERE AcctUniqueId = '%{Acct-Unique-Session-Id}'"
}
}
}
post-auth {
reference = ".query"
query = "INSERT INTO radpostauth (username, pass, reply, authdate ) VALUES ( '%{SQL-User-Name}', '%{%{User-Password}:-%{Chap-Password}}', '%{reply:Packet-Type}', '%S.%M' )"
}
}
Could not link driver rlm_sql_mysql: dlopen(/opt/homebrew/Cellar/freeradius-server/3.2.6_2/lib/rlm_sql_mysql.dylib, 0x0006): tried: '/opt/homebrew/Cellar/freeradius-server/3.2.6_2/lib/rlm_sql_mysql.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/freeradius-server/3.2.6_2/lib/rlm_sql_mysql.dylib' (no such file), '/opt/homebrew/Cellar/freeradius-server/3.2.6_2/lib/rlm_sql_mysql.dylib' (no such file)
Make sure it (and all its dependent libraries!) are in the search path of your system's ld
/opt/homebrew/Cellar/freeradius-server/3.2.6_2/etc/raddb/mods-available/sql[27]: Instantiation failed for module "sql"
I checked, and there's no rlm_sql_mysql in the directory. Please help me with this. Thanks.
More information about the Freeradius-Users
mailing list