Understanding RADIUS Accounting
RADIUS accounting works alongside authentication to log session data. Every time a subscriber connects, the NAS (your MikroTik router) sends accounting packets to the RADIUS server: Accounting-Start when the session begins, Interim-Updates at regular intervals, and Accounting-Stop when the session ends.
Each accounting record includes: username, session duration, bytes uploaded, bytes downloaded, NAS IP, assigned IP address, and termination cause. This data is essential for usage-based billing, FUP enforcement, and network analytics.
Configuring Accounting on MikroTik
Enable RADIUS accounting for PPPoE and Hotspot services:
# Enable PPP RADIUS accounting /ppp aaa set use-radius=yes accounting=yes interim-update=5m # Enable Hotspot RADIUS accounting /ip hotspot profile set default radius-accounting=yes radius-interim-update=5m # Verify RADIUS configuration /radius print detail
The interim-update=5m setting is crucial — it sends usage data every 5 minutes. Without it, you only get usage totals when the session ends, which could be days later for always-on PPPoE connections.
Reading Accounting Data
RADIUS accounting data is stored in the radacct table in your FreeRADIUS database. Here are useful queries:
# Top 20 data consumers today mysql -e "SELECT username, ROUND(SUM(acctinputoctets)/1073741824, 2) AS upload_gb, ROUND(SUM(acctoutputoctets)/1073741824, 2) AS download_gb, ROUND(SUM(acctinputoctets + acctoutputoctets)/1073741824, 2) AS total_gb FROM radacct WHERE acctstarttime >= CURDATE() GROUP BY username ORDER BY total_gb DESC LIMIT 20;" radius # Monthly usage per subscriber mysql -e "SELECT username, ROUND(SUM(acctinputoctets + acctoutputoctets)/1073741824, 2) AS total_gb FROM radacct WHERE acctstarttime >= DATE_FORMAT(NOW(), '%Y-%m-01') GROUP BY username ORDER BY total_gb DESC;" radius
Implementing Fair Usage Policy (FUP)
FUP throttles subscribers who exceed a data cap to a lower speed tier. This ensures fair bandwidth distribution across all subscribers. The typical workflow:
- Define FUP thresholds — e.g., 300 GB/month for 10 Mbps plan, after which speed drops to 2 Mbps
- Monitor usage — track cumulative usage from RADIUS accounting data
- Trigger throttle— when threshold is reached, change the subscriber’s RADIUS rate-limit attribute
- Apply via CoA — send Change of Authorization to MikroTik to apply the reduced speed immediately
- Reset monthly — restore original speed at the beginning of each billing cycle
Data Cap Alerts and Notifications
Proactive communication keeps subscribers happy. Send alerts at usage milestones:
| Threshold | Action | Channel |
|---|---|---|
| 75% of data cap | Warning notification | SMS + App notification |
| 90% of data cap | Urgent warning | SMS + Email |
| 100% of data cap | FUP speed reduction applied | SMS + Email + Speed change |
| Top-up purchased | Speed restored | SMS confirmation |
How ISPbills Automates Usage Billing
ISPbills reads RADIUS accounting data and automates the entire usage billing workflow:
- Real-time usage tracking — per-subscriber usage graphs updated every 5 minutes from interim accounting
- FUP automation — define FUP rules per package and ISPbills handles throttling and restoration automatically
- Data cap alerts — configurable SMS/email notifications at 75%, 90%, and 100% thresholds
- Usage-based billing — charge subscribers per GB of usage with automatic invoice generation
- Top-up system — subscribers can purchase additional data packages through the customer portal
- Usage reports — monthly usage reports per subscriber, per package, and network-wide
Ready to Automate Your ISP?
ISPbills handles billing, network provisioning, and customer management. Use Free Demo to evaluate with up to 100 active subscribers.