Aller au contenu

MikroTik RouterOS

This page covers the built-in MikroTik template: RouterOS administrator login and PPP (L2TP) VPN through OkYouIn. For RADIUS concepts see RADIUS.

PlatformSoftwareModesWhat was verified
MikroTik CHRRouterOS 7.5password, password + MFAAdmin login over SSH and the API port (MS-CHAPv2) with local and Active Directory users; L2TP PPP with PAP and MS-CHAPv2; e-mail Approve link as second factor; accounting Start / Interim / Stop; Mikrotik-Group, Framed-IP-Address, Mikrotik-Rate-Limit, Mikrotik-Address-List, Session-Timeout (PPP)

Not verified: WebFig and WinBox logins, SSTP and OVPN, and Telegram / Web Push approvals (they work the same way as the e-mail link on the OkYouIn side, but were not exercised on this device).

First factorOkYouIn checks the password only; MFA only is not available.
Second factorApproval only: Telegram, Web Push (without number matching) or the Approve link of an e-mail. MS-CHAPv2 and PAP carry no code and RouterOS shows no Access-Challenge, so users with TOTP are refused (reason incompatible_method).
PromptsNone — the login waits while the user approves.
AccountingAdmin logins and PPP; PPP with tunnel address, session time and counters.
Client IPCalling-Station-Id is the SSH / API client or the PPP caller.

The e-mail Approve link needs the public base URL of OkYouIn to be set. See MFA methods.

  1. Passwords for MS-CHAPv2. The admin login (/user aaa) uses MS-CHAPv2. OkYouIn local users work once their password has been set (OkYouIn keeps the NT hash from then on). Directory users need Active Directory with the domain joined, or FreeIPA publishing the NT hash — see Directories.

  2. In OkYouIn, open Access ▸ Applications ▸ Add application and pick MikroTik. The Connect tab shows the commands below with real values.

  3. Identify the router by its address. RouterOS 7.5 sends no Message-Authenticator in Access-Request, so OkYouIn must recognise the router by its source address: add it under Sources. If the Settings tab warns that the application is selected by NAS-Identifier, its requests are dropped — give it a source of its own.

  4. NAS-Identifier. RouterOS sends its system identity (/system identity print) as NAS-Identifier in every request. Either set the application’s NAS-Identifier to that value, or leave it empty and identify by source. Change the identity with /system identity set name=<value>.

The example uses 192.0.2.10 for OkYouIn. RouterOS needs IP addresses: replace <ROUTER-IP> with the router address OkYouIn receives the requests from.

/radius add address=192.0.2.10 secret="<SHARED-SECRET>" service=login \
authentication-port=1812 accounting-port=1813 timeout=60s \
src-address=<ROUTER-IP> comment="OkYouIn"
/user aaa set use-radius=yes accounting=yes interim-update=0s default-group=read

For PPP (L2TP) as well:

/radius set [find comment="OkYouIn"] service=login,ppp
/ppp aaa set use-radius=yes accounting=yes interim-update=0s

Notes:

  • timeout=60s: RouterOS sends one request and waits that long without retrying, so the approval must come within about 55 seconds. For PPP RouterOS warns that a timeout above 3 s may make PPP authentication time out; a Linux pppd client still connected after a 44-second approval, other VPN clients may give up sooner.
  • default-group=read: users without a Mikrotik-Group reply attribute, or with a group that does not exist, get the default group. Keep it read so a missing or mistyped group never grants full.
  • Local users (/user) are checked before RADIUS. With several RADIUS servers for service=login, RouterOS asks the next one only when a server does not answer — a reject is final — so OkYouIn must be the only login server.

Set these in the application’s Rules tab.

AttributeApplies toEffect
Mikrotik-GroupAdmin loginRouterOS user group (read, write, full or your own).
Framed-IP-AddressPPPThe client’s tunnel address (instead of the PPP profile’s pool).
Mikrotik-Rate-LimitPPPSpeed limit rx/tx as seen by the router, e.g. 1M/2M — a dynamic simple queue.
Mikrotik-Address-ListPPPFirewall address list the client’s address is added to while connected.
Session-TimeoutPPPEnds the connection after N seconds. Admin logins ignore it.
ClassBothEchoed in accounting. A Class from a rule replaces OkYouIn’s own Class token.

/user aaa accounting=yes sends Start and Stop for admin logins, /ppp aaa accounting=yes for PPP — both are the defaults. Every Accounting-Request carries NAS-Identifier, User-Name, Calling-Station-Id and Class; PPP adds Framed-IP-Address, session time and byte / packet counters, and the Stop the terminate cause.

With interim-update=0s RouterOS sends Interim-Update at the application’s Interim interval (seconds) (300 by default for this template); leave it empty for none.

RouterOS sends Accounting-On the first time it uses the server: OkYouIn then closes that router’s open sessions. This is expected at set-up.

Keep Protection mode (CVE-2024-3596) at Standard, the default. Strict breaks this router: RouterOS 7.5 never sends Message-Authenticator, so every request would be dropped.

  1. Open a new SSH session as an OkYouIn user and approve the push or e-mail link.

  2. In Logging ▸ RADIUS log you will see one reject with reason empty_password_probe per SSH login, followed by the real request: RouterOS tries an empty password before every SSH login. This is expected.

  3. Check the application’s Sessions tab for the session.

SymptomLikely cause
Reject incompatible_methodThe user’s MFA method is TOTP or an e-mail code; give them a push method or the e-mail link.
No answer, request missing from the logCheck Logging ▸ RADIUS log ▸ Dropped packets: no Message-Authenticator (Strict mode, or the application is selected by NAS-Identifier), or an unknown source.
MS-CHAPv2 reject such as “No NT hash for the account”A local user whose password was never set in OkYouIn, or a directory without domain join / NT hash.
User lands in the read groupNo Mikrotik-Group in the matching rule, or the group name does not exist on the router.