Login to MikroTik device via Synology RADIUS (with LDAP and group mapping)
/ 4 min read
Updated:Recently, I have been working on setting up our university lab’s new network architecture and MikroTik network equipment.
One of them is we want our network admins to be able to login to MikroTik management interfaces (Eg, WinBox) using their LDAP credentials.
Our lab currently uses Synology’s LDAP and RADIUS servers. (However, I am also experimenting with FreeIPA, FreeRADIUS, and Kanidm, as we might need to migrate to a more scalable and robust solution.)
Therefore, for this article, I’ll be focusing on Synology RADIUS. Still, some of the configurations here might also be applicable with FreeRADIUS, as Synology RADIUS is a FreeRADIUS server with custom configurations.
1. Modify Synology RADIUS server configuration files
Enable and login to SSH on your Synology system using an admin account.
Make sure to disable the SSH after finishing the configuration, as the Synology system allows SSH password login by default, which adds additional security risk if you leave it on.
Switch to root user with sudo
and authenticate using the password of your admin account:
The original FreeRADIUS LDAP configuration provided by Synology is missing membership_attribute
, which prevents the server from filtering the LDAP group properly.
Fix by adding this new line to Synology RADIUS’ FreeRADIUS LDAP configuration file, located at /var/packages/RadiusServer/target/etc/raddb/mods-enabled/ldap
:
Then, create a file in /usr/local/synoradius/mikrotik_admin
, with the configuration to map the LDAP group to the MikroTik group:
The definition of these RADIUS attributes:
Ldap-Group
: FreeRADIUS documentationMikrotik-Group
: MikroTik documentation
Finally, depending on your settings of “Source for user authentication” in Synology RADIUS, modify the corresponding file located in /usr/local/synoradius/
:
Configuration file | Source for user authentication |
---|---|
rad_site_def_ldap | Only LDAP users |
rad_site_def_local_ldap | Both Local users and LDAP users |
rad_site_def_local | Only Local users |
rad_site_def_ad | Only Domain users |
rad_site_def_local_ad | Both Local users and Domain users |
This article focuses on authentication with only LDAP users, though you can still try tinkering with configurations that fit your requirements.
Modify file /usr/local/synoradius/rad_site_def_ldap
to include the previously created mikrotik_admin
file in the post-auth
section:
Stop and start the Synology RADIUS server in the package center, and you have finished the part of setting up the Synology RADIUS server.
2. Setup MikroTik device for RADIUS Login
Connect to your MikroTik device’s console.
Add the RADIUS server and allow it to login to your MikroTik device:
Enable RADIUS login to your MikroTik device:
I also strongly recommend setting the default-group
option to your desired MikroTik user group, it’s for every user that is not mapped by your RADIUS configuration above.
As default-group
has a default value read
, which, by default, allows every unmapped user to login to your MikroTik device with read
group permission. Which might not be the setup you wanted.
And that’s it, you have finished the setup. Try login to your MikroTik device using the LDAP credential \(^▽^)/
Further Reading
Setting up FreeRADIUS to work with MSCHAPv2 with FreeIPA:
-
https://fy.blackhats.net.au/blog/2015-07-06-freeipa-giving-permissions-to-service-accounts/
-
https://fy.blackhats.net.au/blog/2016-01-13-freeradius-using-mschapv2-with-freeipa/
See also
FreeIPA and Red Hat IdM Password Auditing:
Blast-RADIUS (CVE-2024-3596):
References
FreeRADIUS Docs:
MikroTik RADIUS:
-
https://help.mikrotik.com/docs/spaces/ROS/pages/2555940/User+Manager#UserManager-Attributes
-
https://help.mikrotik.com/docs/spaces/ROS/pages/8978504/User#User-RemoteAAA
-
https://help.mikrotik.com/docs/spaces/ROS/pages/328097/RADIUS#RADIUS-RADIUSClient
Synology RADIUS: