Skip to content

Random Mac Synchronization

ivanalayan15 edited this page Sep 23, 2021 · 5 revisions

Introduction

There's no really a fix for random mac address currently available for Mikrotik, and its more on mikrotik side to develop a way how to do the synchronization. But there are many ways how to solve the issue currently our system.

This solution not only applies to JuanFi system but also can be apply to other system as well like voucher system.

Concept

Ideally a VOUCHER is own by one device, and a VOUCHER can be use by one device only, so means a voucher can be use by 1 device at a time.

For a device that have a random mac address when it connects, its not applicable since when you will have different identification to the mikrotik system. So means if theres an existing session of that voucher already in previous MAC address, you will not able to login anymore.

To fix the issue, we need to have assumptions

  1. A voucher can be use by 1 device at a time
  2. When the voucher is use by a new device(new address) we will kick out the previous session
  3. No mac fix address in your voucher

Implementation

Base on the script above we have the idea how to solve the current issue doing it manually actually is easy but we want it to be automated whenever the user do a login. I created a script below and to implement the idea

This solution does not need any integration with the nodemcu / esp its a direct solution in Mikrotik

1.) Change the hotspot user profile setting, actually you will think this is crazy but the idea is only 1 active user at a time so any value you put here as long as its > 1 it will work, the goal is that we can allow the 2nd login to be success and the next step will do the magic. alt text

2.) Add this script in the hotspot user profile on the on login event script, this script is the one do the kicking of previous session when its not equal to the current login mac address.

:local cmac $"mac-address"
:foreach AU in=[/ip hotspot active find user="$username"] do={
  :local amac [/ip hotspot active get $AU mac-address];
  :if ($cmac!=$amac) do={  /ip hotspot active remove [/ip hotspot active find mac-address="$amac"]; }
}

alt text

3.) Test it, and enjoy!!

Clone this wiki locally