gremigio
Goto Top

Freeradius and MYSQL

Hello,

I am working with freeradius and MYSQL. My goal is to authenticate users through the radius server with my users' database in mysql. I already have all the users created in mysql but when I try to establish an authentication I get the error that freeradius cannot establish the connection with the database.

Content-ID: 669785

Url: https://administrator.de/contentid/669785

Printed on: December 7, 2024 at 17:12 o'clock

NordicMike
NordicMike Nov 26, 2024 at 15:42:22 (UTC)
Goto Top
By default the MySQL Database is accepting local queries only. You have to grand privileges to the user@% (all localtions), then your radius server is not at the same computer like the database. If its a windows MySQL server then the TCPIP protocol is disabled by default in the MySQL server settings.
Gremigio
Gremigio Nov 26, 2024 at 15:52:10 (UTC)
Goto Top
In my case I have freeradius and mysql, the same Ubuntu operating system, and I have given all rights to the database.

When I perform the test from safe mode this is what I have
screenshot 2024-11-26 114911
aqui
Solution aqui Nov 26, 2024, updated at Nov 27, 2024 at 09:23:25 (UTC)
Goto Top
Take a look at a local tutorial:
Freeradius with database and GUI which describes all steps in detail. Use a translator to read it in English or your language of choice. face-wink
In case you have the database on a separate server the most important config is under /etc/freeradius/3.0/mods-available/sql
Instead of "localhost" in the connection you have to setup the database IP address here. In case you need to encrypt the session you maybe want to activate all the TLS settings in the connection screenshot above. You should make sure that a ping between radius and database works and proofs a running IP connection. Database ports should be open in a firewall and in the database setting itself so that it accepts remote access. There are also some easy checks for a remote client connectivity:
https://mariadb.com/kb/en/configuring-mariadb-for-remote-client-access/

If database and Radius Server are on the same system (localhost) just follow the above tutorial!! This will bring things instantly to work.
So far the posted debug output looks quite ok for the Radius authentication itself but looks like there is no network (or local) connection to the database and therefor the user "user1" could not be looked up and fails authentication.
Gremigio
Gremigio Nov 26, 2024 at 19:37:58 (UTC)
Goto Top
I'm reviewing what you sent me since I finished the test. I'll let you know.

Thank you very much bro.
Oskar44
Solution Oskar44 Nov 28, 2024 updated at 14:55:49 (UTC)
Goto Top
The error message is clear and can be read in the log

screenshot

You have not modified the configuration to fit the needs for your database system. So open /etc/raddb/mods-enabled/sql and change the line dialect line to
dialect = "mysql"  
and comment out the line with "rlm_sql_null" and remove the comment from the next line
#	driver = "rlm_sql_null" 
        driver = "rlm_sql_${dialect}"  
Then inside the section sql {} add the correct connection details to your database
# server address
server = "localhost"  
# server port
port = 3306
# username 
login = "radius"  
# password 
password = "Passw0rd"  
# database name
radius_db = "radius"  
Afterwards restart the radius service.
Gremigio
Gremigio Nov 28, 2024 at 18:39:45 (UTC)
Goto Top
Thank you very much for the comment, I had those same settings but somehow it generated errors so I decided to configure it completely with the guide that you provided me and it worked for me.

Thank you very much
Series: Freeradius Y MYSQL 1
Freeradius and MYSQL6