Hotspot Users

Lock Hotspot User to First Device (MAC Binding) — v6 & v7

On-Login script: when a voucher is used for the first time it saves the device's MAC address in the user, so the same voucher cannot be used on other devices afterwards.

MikroTik Version

RouterOS v6 & v7

# EN: $user and $"mac-address" are provided by the hotspot at login | AR: المتغيران $user و $"mac-address" يوفرهما الهوتسبوت عند الدخول
:do {
    :local row [/ip hotspot user find where name=$user];
    :local saved [/ip hotspot user get $row mac-address];
    # EN: Save the MAC only if the user has none yet | AR: حفظ الـ MAC فقط إذا لم يكن للمستخدم MAC محفوظ
    :if ([:len $saved] = 0 || $saved = "00:00:00:00:00:00") do={
        /ip hotspot user set $row mac-address=$"mac-address";
        :log warning ("hotspot: " . $user . " locked to " . $"mac-address");
    }
} on-error={ :log warning ("hotspot: cannot lock MAC for " . $user) }