Change subject to some like Need script to do this and that.
Always use code tags for your code. Select the your code and click the fifth button </>
Then it becomes like this (added tabs to make it more easy to read):
:local mac $leaseActMAC
:local host $"lease-hostname"
:global leaseBound
:if ($leaseBound = 1) do={
:local maccheck [/ip firewall mangle print count-only where comment~"$mac"]
:local hostcheck [/ip firewall mangle print count-only where comment="$host - $mac "]
:if ($maccheck = 0) do={
:log info "$mac not registered previously, allowed"
}
:if (($maccheck = 1)&&($hostcheck = 0)) do={
:log info "error $mac already registered with different hostname, removing previous session"
/ip hotspot cookie remove [find mac-address=$mac]
/ip hotspot active remove [find mac-address=$mac]
}
:if (($maccheck = 1)&&($hostcheck = 1)) do={
:log info "$mac registered with correct hostname $host"
}
}
:if ($leaseBound = 0) do={
:log info "$mac dhcp assign removed"
}
This script seems to be a part of some other script. For example, I do not see where variable $leaseActMAC is set.
I am looking for a dhcp lease script, have search my all for many days , and I found what I want .
But it is not completed .
I want the script to match the combo of “host name - Mac” to previously saved “host name - Mac” in firewall mangle comments ( which is used to log traffic of users in hotspot).
If it matches dhcp lease should be good to go.
If it doesn’t match it should be released
If the comments dont exist for first time login dhcp should be good to go.
I need help with this script
1 - script to add mangle rules, add comment based on host name - Mac combo
2 - script to remove said rules and comments on expiry of hotspot user session.
Somebody here have written this script
But he doesn’t complete it .
I think it need the login user profile script to got it work .
Sorry for my bad English
Help me
Thanks