Hello,
I’m trying to setup an “advenced” hotspot on the RouterOS. Basic configuration covered by official documentation works
like a charm but the goal is to create the hotspot for a dormitory with additional rules:
-
After first login, the Mac Address should be bound to the user
-
The static lease should be created on the DHCP to bind Mac Address to the IP - we want the user to use “static” address assigned from dhcp and
we don’t want this address to be changed during the accommodation.
I came out with hotspot user profile on login script:
:local u [/ip hotspot user find name=$username ];
:if ([:len $u] > 0) do {
:if ([:len [/ip hotspot user get $u "mac-address"]] < 1) do {
# bind mac address to the user
/ip hotspot user set $u mac-address=$"mac-address";
# convert the dynamic lease into the static lease
:local lea [/ip dhcp-server lease find mac-address=$"mac-address"];
log info message=$lea;
/ip dhcp-server lease make-static $lea;
}
}
the first part works (binding mac to user) but unfortunatelly, for some reason, after each login,
all the leases are coverted to the static leases. Following line:
/ip dhcp-server lease find mac-address=$"mac-address"
returns array containing ALL leases and should return only one lease which corresponds to the mac address.
I can see it in the log: “*2;*3;*4”
funny thing is, when I try to execute command like:
:put [/ip dhcp-server lease find mac-address=08:00:27:8B:C4:CD]
outside of the script, it displays only ONE element (as expected).
What am’i missing? Is it bug or my mistake?
Best regards,
Alek.
hotspot2.rsc (3.21 KB)
