Community discussions

MUM Europe 2020
just joined
Topic Author
Posts: 9
Joined: Tue Jul 10, 2018 6:38 am

New Mikrotik - Using API to log users instead of RADIUS server

Tue Jul 10, 2018 6:44 am

Hello everyone,

Nice to meet you, my name is Hector Alcazar, I am a fullstack developer and I have a requirement to work on the creation of a login portal. Sincerely I have not worked with RADIUS and I want to skip that step, through the API, is it possible to log users using my own database?
User avatar
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: New Mikrotik - Using API to log users instead of RADIUS server

Sat Jul 14, 2018 6:04 pm

I assume you mean hotspot users.

Yes, it's possible, but how easy it is depends on your topology.

On successful authentication with your database, you'll need to create a temporary hotspot user with the API using the "/ip hotspot user add" command, then call the "/ip hotspot active login" command to then bind that user to the internal IP address of the device the user is on. Ideally, you want to add an "on-logout" script at their profile that will remove the user from hotspot as soon as they log out.

If your router is in the same network as your web server, your web server will just know the IP address. If the router has a public IP, but your web server is not in the same network, you'll need to lookup the "/ip firewall connections" menu for their connection to your web server. Your server can tell you the IP and port the client is using at the router, which is enough to uniquely identify them in there, and from there, you'll get their private IP.

If your router does not have a public IP (i.e. you have a "double NAT" situation), and your web server is outside of the network, you'll need to setup a VPN between the router and web server, and then proceed to use the VPN IP as if it's a public one AND make sure users enter your web page through the VPN connection (so that you can look them up in the "/ip firewall connections").
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
Long time Member
Long time Member
Posts: 639
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: New Mikrotik - Using API to log users instead of RADIUS server

Mon Oct 01, 2018 7:00 pm

Please don't re-post your question over-and-over again.


User danikf has answered your question regarding C#:
of course ...
... if you are able to read previous posts ...
var user = new HotspotUser()
    Name = "TEST",
    LimitUptime = "1:00:00",
    Password = "secretpass"

Who is online

Users browsing this forum: No registered users and 6 guests