
FreeRADIUS is a popular open-source RADIUS (Remote Authentication Dial-In User Service) application for managing network access through user authentication, authorization, and accounting services (AAA). When you install FreeRADIUS, it integrates with database engines such as PostgreSQL for centralized user management.
This article explains how to install and configure FreeRadius with PostgreSQL to create a reliable RADIUS solution.
Before you begin:
FreeRADIUS is available in the default package repositories on Ubuntu. Follow the steps below to install FreeRADIUS and the dependency plugin for PostgreSQL on your server.
Install FreeRADIUS and the PostgreSQL plugin.
Check the FreeRADIUS version.
Output:
FreeRADIUS requires a specific schema to work with database servers such as PostgreSQL. Follow the steps below to create a new schema file that contains the default tables and fields to use with PostgreSQL.
Create a new freeradius_schema.sql schema file in a system-wide location such as /opt.
Edit the file using a text editor such as nano.
Add the following database schema to the file.
Save and close the file.
The above schema creates the following database tables for FreeRADIUS:
radcheck: Stores user-specific authentication attributes, such as usernames and passwords.radreply: Stores reply attributes after a successful authentication, such as session limits and IP assignments.radgroupcheck: Stores group-specific authentication attributes.radgroupreply: Stores group-specific reply attributes after a successful authentication.radusergroup: Associates users with groups. For example, maps user A to the VIP Wi-Fi group.radacct: Stores accounting records on how users interact with a network. For example, the session start time, data usage, stop-time, and other usage metrics.radpostauth: Logs successful and failed authentication attempts including the username, timestamp, and authentication response.nas: Stores information about the Network Access Servers (NAS) that send the authentication, authorization, and accounting requests to the FreeRADIUS server.nasreload: Enables dynamic reloading of NAS configurations to the FreeRADIUS memory.Access the PostgreSQL database server console as the postgres user.
Modify the postgres user password.
Exit the PostgreSQL console.
Create a new freeradius database to use with FreeRADIUS.
Run the following command to enable password authentication on the PostgreSQL database server. Replace 17 with the actual PostgreSQL version on your server.
Import the freeradius_schema.sql file to the freeradius database.
Output:
Log in to the PostgreSQL database server as the postgres user and switch to the freeradius database.
Verify that all FreeRADIUS tables from your schema are available.
Output:
Create a new sample user in the radcheck table. For example, kiki and set the user's password to 1234.
Query the radcheck table to view the available records.
Output:
Create a new test server in the nas table.
Query the nas table to verify the available servers.
Output:
Exit the PostgreSQL database console.
Follow the steps below to configure FreeRADIUS to work with the PostgreSQL database server.
Enable the FreeRADIUS SQL module by creating a symbolic link in the mods-enabled configurations directory.
Open the default FreeRADIUS configuration file.
Find the following -sql directive and remove the - symbol to enable the SQL directive.
Open the /sites-available/inner-tunnel file.
Find the following SQL directives and remove the - or # symbols to enable each directive.
Save and close the file.
Open the /mods-available/sql file.
Find the following dialect directive and change the value from SQLite to PostgreSQL.
Find the driver directive and change the value from rlm_sql_null to rlm_sql_${dialect} to integrate FreeRADIUS with PostgreSQL.
Find the database connection section, uncomment all directives, and enter your PostgreSQL database information in the respective fields.
Find the radius_db directive and change the value from radius to the FreeRADIUS database you created earlier.
Find and uncomment the read_clients directive to enable FreeRADIUS to read client details from the nas table.
Save and close the file.
Follow the steps below to test the FreeRADIUS integration with PostgreSQL. You will authenticate with your local server using the test user you created earlier in the radcheck table to verify that FreeRADIUS successfully reads data from the database.
Stop the FreeRADIUS system service.
Start FreeRADIUS in debugging mode as a background process to view detailed process information.
Output:
If you receive the following error when starting the server:
Run the following command to get the FreeRADIUS process ID.
Output:
Stop the freerand process by specifying the ID, such as 9374 based on the above output.
Start the server again in debugging mode.
Run the radtest utility and try authenticating to the FreeRADIUS server as kiki and specify 1234 as the password.
Output:
The Received Access-Accept... response in the above output shows that you have successfully authenticated to the server.
You have installed and configured FreeRADIUS with PostgreSQL to enable real-time authentication on a server. You can use FreeRADIUS to perform user authentication and authorization tasks. In addition, you can also use group-based access control by utilizing the RadGroupCheck and RadGroupReply tables in PostgreSQL to store attribute checks for specific user groups. After you install FreeRADIUS, you will have more configuration options; please visit the FreeRADIUS documentation.
0 Comments
Be the first to comment and share your perspective with the community.