Skip to main content

ArtinTech Solution

Freeradius packages in Linkhive

FreeRADIUS can read users and policies from a SQL database, which makes a FreeRADIUS Laravel integration surprisingly simple: billing writes rows and the RADIUS server applies them. In Linkhive, this sits behind the same driver interface as MikroTik, so the billing code does not know which one a provider uses.

Packages become groups

Each package becomes a RADIUS group. Reply attributes go in radgroupreply, and a check attribute limits simultaneous sessions:

$replies = ['Mikrotik-Rate-Limit' => $plan->bandwidthProfile->rateLimit()];

if ($plan->ipPool) {
    $replies['Framed-Pool'] = $plan->ipPool->name;
}
if ($plan->data_limit_mb) {
    $replies['Mikrotik-Total-Limit'] = (string) ($plan->data_limit_mb * 1024 * 1024);
}

The group is rewritten inside a transaction, so a change never leaves it half updated. The speed attributes are MikroTik’s, so a MikroTik network device is the natural partner here.

Linkhive packages list with hotspot and PPPoE packages, speeds, validity, prices and active users
Each package becomes a RADIUS group with its speed and session limits.

Suspending a customer

Suspension adds one row to radcheck: Auth-Type := Reject. Paying removes it. The record stays in place, so reconnecting needs no rebuild.

Know the limit

SQL cannot end a live session. A suspended customer stays online until their next authentication, unless the router can also be reached through its API. We documented that in the code rather than hide it, and it is worth planning for with a sensible session timeout.

Key takeaways

  • Map packages to RADIUS groups, and customers to rows.
  • Rewrite group attributes in one transaction.
  • Plan for the fact that SQL changes do not disconnect live sessions.

See how it fits together in the Linkhive live demo or get Linkhive on Vibe96. Need help with a RADIUS rollout? Let’s Talk, or see our Laravel development service.

Share this article