A production MikroTik PPPoE FreeRADIUS setup has to survive exactly the moments described below.
DHCP is fine until you need to bill people. The day a subscriber swaps their router, disputes their usage, or you need to throttle a plan across twelve towers, PPPoE with FreeRADIUS is the stack that holds up.
Here is the working shape of it, end to end.
MikroTik PPPoE FreeRADIUS Setup Architecture
Subscriber CPE ──PPPoE──> MikroTik BNG ──RADIUS──> FreeRADIUS ──SQL──> PostgreSQL │ │ rate limit accounting (dynamic queue) (billing source) RouterOS is the BNG (broadband network gateway). It terminates PPPoE sessions and asks FreeRADIUS a single question: may this user in, and at what speed?

1. PPPoE server on RouterOS
/ip pool add name=pppoe-pool ranges=10.50.0.2-10.50.255.254 /ppp profile add name=pppoe-default local-address=10.50.0.1 remote-address=pppoe-pool \ dns-server=10.50.0.1 use-encryption=no only-one=yes /interface pppoe-server server add service-name=isp interface=bridge-access default-profile=pppoe-default \ authentication=pap,chap one-session-per-host=yes disabled=no only-one=yes et one-session-per-host=yes together stop credential sharing between households — the single highest-value line in this file.
2. Point RouterOS at RADIUS
/radius add service=ppp address=10.60.0.5 secret=<strong-shared-secret> \ timeout=800ms src-address=10.60.0.1 /ppp aaa set use-radius=yes accounting=yes interim-update=5m /radius incoming set accept=yes port=3799 interim-update=5m is the sweet spot. Shorter floods the RADIUS server on a large base; longer and a mid-session disconnect loses too much usage data to bill fairly.
RADIUS redundancy without a split-brain mess
One FreeRADIUS instance is a single point of failure for every new PPPoE login on the network, even though existing sessions stay up fine without it. RouterOS accepts multiple RADIUS entries and tries them in order:
/radius add service=ppp address=10.60.0.5 secret=<strong-shared-secret> timeout=800ms src-address=10.60.0.1 add service=ppp address=10.60.0.6 secret=<strong-shared-secret> timeout=800ms src-address=10.60.0.1 The real work is not the RouterOS side – it is keeping both FreeRADIUS instances reading the same PostgreSQL data without writing conflicting accounting rows. Point both at one PostgreSQL primary (a read replica for reporting queries is fine, but radacct writes need one source of truth), and keep the shared secret identical on both so a failover is invisible to the BNG. Test the failover by actually stopping the primary FreeRADIUS process during a quiet window, not by assuming the second entry works because it is configured.
3. FreeRADIUS with SQL
Enable the sql module and store plans as reply attributes rather than hard-coded queues:
-- Plan: Home 20 Mbps, burst to 25 for 15s INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('home-20', 'Mikrotik-Rate-Limit', ':=', '10M/20M 12M/25M 10M/20M 15'); -- Assign a subscriber to a plan INSERT INTO radusercheck (username, attribute, op, value) VALUES ('ali.k', 'Cleartext-Password', ':=', 'change-me'); INSERT INTO radusergroup (username, groupname, priority) VALUES ('ali.k', 'home-20', 1); Le Mikrotik-Rate-Limit syntax is rx/tx burst-rx/burst-tx threshold-rx/threshold-tx burst-time. Direction is from the router's point of view, so the first value is the subscriber's téléversement. Get this backwards and every customer reports "my download is only 10 Mbps" — I have made that call myself.
4. Suspend and restore without touching the router
Non-payment handling should never mean logging into a RouterOS box. Move the subscriber to a restricted group and send a disconnect:
echo "User-Name=ali.k,Acct-Session-Id=81a0043c,NAS-IP-Address=10.60.0.1" \ | radclient -x 10.60.0.1:3799 disconnect <shared-secret> Next reconnect they land in the suspended group, whose reply attributes point DNS at a payment-reminder page and cap the rate at 512k. Pay, group flips back, session resets, service restored. No truck roll.
Testing before it touches real subscribers
radtest confirms the RADIUS side answers correctly before a single real PPPoE session depends on it:
radtest ali.k change-me 10.60.0.5 0 <shared-secret> A clean Access-Accept with the expected Mikrotik-Rate-Limit attribute in the reply means the SQL groups and reply attributes are wired correctly, independent of anything on the router. Run this from the FreeRADIUS box itself first, then from the RouterOS network – a pass locally but a timeout from the BNG subnet means a firewall rule on UDP 1812/1813, not a FreeRADIUS config problem, and it saves an hour of debugging the wrong layer.
Before cutting real subscribers over, build one test PPPoE profile with a deliberately low rate limit and confirm the full suspend-and-restore flow end to end: disconnect via radclient, reconnect, confirm the restricted group applies, flip the group back, reconnect again. If that round trip does not work cleanly on a test account, it will not work at 2 am on a real one either.
5. Accounting you can actually bill from
radacct gives you start time, stop time, input and output octets per session. Two practical notes:
- Utiliser
BIGINTcolonnes. Les compteurs octets 32 bits se réinitialisent à 4 GB et une seule soirée de streaming corrompra une facture. - Réconciliez chaque semaine avec les compteurs d'interface. Les sessions qui se terminent lors d'une coupure d'alimentation se ferment avec un enregistrement de fin obsolète ; les mises à jour intermédiaires sont ce qui vous sauve.
Dimensionnement et modes de défaillance
| Symptôme | Cause habituelle |
|---|---|
| Déconnexions aléatoires de session à la même heure chaque jour | Timeout RADIUS trop serré, ou verrouillage de sauvegarde de DB radacct |
| Les vitesses ignorent le forfait | Limitation de débit inversée, ou une file d'attente statique qui remplace la dynamique |
| Les sessions restent après le redémarrage du CPE | Non only-one=yes; la session obsolète conserve le nom d'utilisateur |
| Pics CPU sur le BNG | Chiffrement PPPoE activé inutilement, ou trop de mises à jour intermédiaires |
Un RB5009 termine confortablement quelques centaines de sessions PPPoE. Au-delà d'environ mille, passez à un BNG de classe CCR et divisez par zone.
Migrating existing DHCP subscribers without a truck roll
Most ISPs running this stack are migrating off a flat DHCP network, not building from zero, and the CPE is usually already in the customer’s hands. The sequence that avoids a site visit:
- Enable PPPoE server alongside DHCP on the same bridge – they coexist fine as long as the IP pools do not overlap.
- Push PPPoE credentials remotely if the CPE supports TR-069/ACS management, or via the CPE’s own cloud app (many consumer ONTs and routers support this) – this is the step that avoids sending a technician out.
- Migrate in small batches per tower, not the whole base at once. A batch of 20-30 subscribers lets you catch a bad default profile before it is a thousand support calls.
- Leave the DHCP pool running until the last batch confirms clean, then decommission it. Do not delete the DHCP server the same week as the first migration batch – it is your rollback path if PPPoE throughput or stability does not match expectations.
Troubleshooting commands that actually tell you something
When a subscriber cannot connect, these four commands – in this order – find the layer that is actually broken faster than guessing:
/ppp active print ; is there even a session attempt reaching the BNG? /radius monitor 0 ; is RouterOS sending Access-Request at all? /log print where topics~"radius" ; what did RouterOS log about the RADIUS exchange? /interface pppoe-server print stats ; auth failures vs. successful sessions, by interface On the FreeRADIUS side, radiusd -X run in the foreground on a non-production instance shows the full attribute exchange for a single test login – the fastest way to see exactly which reply attribute is missing or malformed before it reaches RouterOS at all.
La suite
CPE quirks worth knowing before the first batch
Not every router behind this setup behaves the same way, and three specific quirks account for most of the “it works for everyone except this one customer” tickets:
- Some older ONTs cache the PPPoE session and will not re-authenticate cleanly after a RADIUS-triggered disconnect until the ONT itself is power-cycled – a soft reboot via the CPE’s own management page is usually enough, no truck roll required.
- MTU mismatches show up as “the internet half-works.” PPPoE’s 8-byte overhead means a CPE still using 1500 MTU on its LAN side will fail on large packets – video calls and some secure sites break while plain web browsing looks fine. Set the PPPoE interface MTU to 1492 on RouterOS and push the matching value to CPE profiles where the vendor exposes it.
- Dual-WAN or mesh CPE sometimes opens two PPPoE sessions from the same household during a failover test, which
one-session-per-host=yesblocks correctly but then logs as a connection failure the customer reports as “my internet won’t connect” rather than “my internet failed over.” Check the PPPoE active list for a second half-open session before assuming a credentials problem.
Une fois l'authentification et la facturation solides, la pièce manquante est la couche métier : forfaits, factures, bons, et une vue de support de qui est en ligne en ce moment. C'est exactement ce que NexaLink place au sommet de cette pile — le même schéma FreeRADIUS, avec une interface opérateur par-dessus.
