How can I configure the MikroTik hotspot so that when a user connects to the Wi-Fi, a free trial is automatically activated for the first 5 minutes without requiring them to see or interact with the login portal?
I found soulution for everyone and there is the script which should be put in dhcp server leases script
But my problem is that IOS devices fail to redirect to portal after the ip binding is done and I have no idea how to fix that
:local mac $leaseActMAC
:local ip $leaseActIP
:log info (“New DHCP connection - IP: $ip, MAC: $mac”)
:local result [/ping $ip count=1]
:if ($result > 0) do={
:log info (“PING OK: $ip ($mac) $hostname is reachable”)
:local user [/ip hotspot user find where name=(“T-” . $mac)]
:if ($user != “”) do={
:log info (“$mac already has trial user and PING OK: T-” . $mac)
} else={
:log info (“$mac does NOT have a trial user yet and PING OK.”)
}
} else={
:local user [/ip hotspot user find where name=(“T-” . $mac)]
:if ($user != “”) do={
:log info (“$mac already has trial user: T-” . $mac)
} else={
:log info (“$mac does NOT have a trial user yet.”)
/ip hotspot user add name=(“T-” . $mac) mac-address=$mac profile=default disabled=no
/ip hotspot ip-binding add mac-address=$mac type=bypassed comment=“Auto trial for $mac”
/system scheduler add name=(“rm-” . $mac) start-time=[:totime ([/system clock get time] + 00:01:00)] interval=0s on-event=(“:local id [/ip hotspot ip-binding find where comment="Auto trial for $mac"]; /ip hotspot ip-binding remove $id; /system scheduler remove [find name="rm-” . $mac . “"]”)
:log info (“Trial user added for $mac”)
}
}
The solution for this was to set dhcp leases time to 5 seconds but Im not sure if this is a good aproach
The usual discussion is whether the Mikrotik 30 minutes default (it was 10 m before) is still too little, 1 hour is fine or 2-4 hours are better (and it depends on the kind of clients the hotspot server will have).
5 seconds seems (to me) pure folly, once you pass a given threshold of (I believe tens, not hundreds) clients, all the router will do is renew leases, and BTW the (mobile) clients will have to ask for renewals every 2.5 seconds.
ok but… is there any way I can force a client for a specific reason to renew his ip ?