A Flask-based Web Application designed to manage FreeRADIUS users, bandwidth limits, and data usage specifically for pfSense Captive Portal. This app allows administrators to create and manage users in FreeRADIUS, set bandwidth limits, and track monthly usage through a user-friendly web interface.
✅ Tested on: pfSense 2.7 (May work on older versions, but not tested).
⚡ Works with: pfSense, Cisco (WISPr), and possibly MikroTik (with modifications).
- 🖥 Web-Based Management: Built with Flask, Bootstrap, and jQuery for a simple and responsive UI.
- 🔑 User Authentication: Add, update, and delete FreeRADIUS users.
- 📊 Usage Tracking: Displays monthly upload/download usage based on FreeRADIUS accounting (
radacct
).- Supports both Gregorian and Jalali calendars for flexible date filtering.
- 🚀 Bandwidth Control: Uses WISPr attributes to enforce upload/download limits.
- 🔄 pfSense Captive Portal Integration: Supports authentication and accounting via RADIUS.
- ⚙️ Custom Firewall Support: Can be modified for MikroTik or other firewalls using RADIUS bandwidth attributes.
This application runs as a Flask web server and connects to a FreeRADIUS MySQL database to manage users.
- pfSense Captive Portal authenticates users via FreeRADIUS.
- Accounting data (upload/download usage) is stored in the
radacct
table. - This app retrieves and displays user data, allowing admins to set bandwidth limits and track usage.
You need a working FreeRADIUS server with a MySQL database. You can run FreeRADIUS on:
✅ A separate virtual machine (VM) (Recommended).
✅ The same server where this application runs (If you prefer).
✅ Directly on pfSense (Not recommended, as pfSense handles FreeRADIUS differently).
Go to Services > Captive Portal and enable the following:
✅ Enable Accounting
✅ Prefer RADIUS Accounting
✅ Use RADIUS pfSense-Bandwidth-Max-Up and pfSense-Bandwidth-Max-Down attributes
This app uses WISPr-Bandwidth-Max-Up/Down for bandwidth limits.
- pfSense and Cisco support WISPr by default.
- MikroTik uses a different method (You will need to modify the code).
git clone https://github.com/mmk-cp/RadiusAdminPanel.git
cd FreeRADIUS-Manager-for-pfSense
pip install -r requirements.txt
Edit .env
(or set environment variables):
MYSQL_HOST=mysql_server_ip
MYSQL_USER=radius
MYSQL_PASSWORD=yourpassword
MYSQL_DB=radius
SECRET_KEY=your_secret_key
Note: Replace
mysql_server_ip
,yourpassword
, andyour_secret_key
with your actual credentials.
python app.py
- The application will start on port 5003.
- Open
http://your-server-ip:5003
in a browser.
- Create users: Add a username and password.
- Delete users: Remove a user and all associated data.
- Modify users: Change passwords.
- Set max upload/download speed (bps).
- Remove bandwidth limits when needed.
- Check total download, upload, and combined usage for any user.
- Monthly usage tracking based on RADIUS accounting records (
radacct
). - Filter usage data by date range: Use either Gregorian or Jalali calendar for flexible reporting.
The app supports filtering user bandwidth usage by date range using both Gregorian and Jalali calendars. This makes it easier for administrators in regions that use the Jalali calendar (e.g., Iran) to monitor and report usage accurately.
To filter usage data:
- Navigate to the Usage page.
- Select the desired calendar type (Gregorian or Jalali).
- Enter the start and end dates.
- View the usage statistics for the specified period.
By default, this app uses:
'WISPr-Bandwidth-Max-Up': upload_speed
'WISPr-Bandwidth-Max-Down': download_speed
If you are using MikroTik or another firewall, you need to:
- Change WISPr attributes to MikroTik's equivalent attributes in
app.py
.- For example, replace
WISPr-Bandwidth-Max-Up
withRate-Limit-Up
.
- For example, replace
- Modify User Profile settings in MikroTik’s RADIUS configuration.
✅ pfSense 2.7 (Tested & working)
✅ Cisco (WISPr support)
-
Unable to connect to MySQL database:
- Ensure the MySQL service is running and accessible from the application server.
- Verify the credentials in
.env
.
-
pfSense RADIUS integration not working:
- Double-check the RADIUS settings in pfSense under Services > Captive Portal.
- Ensure accounting is enabled and configured correctly.
-
Bandwidth limits not applied:
- Confirm that the correct WISPr attributes are being used.
- Check if the firewall supports these attributes.
-
Date filtering not working:
- Ensure the
jdatetime
library is installed (pip install jdatetime
). - Verify that the date format matches the expected input (YYYY/MM/DD for Jalali).
- Ensure the
If you find a bug or want to improve the project:
- Fork the repository.
- Make your changes.
- Submit a Pull Request.
We welcome contributions to enhance functionality, fix bugs, or improve documentation!
This project is licensed under the MIT License. See LICENSE for more details.