24 lines
1.2 KiB
Text
24 lines
1.2 KiB
Text
/system scheduler remove [find name=opt82-hotspot-sync]
|
|
/system script remove [find name=opt82-hotspot-sync]
|
|
:delay 1s
|
|
/system script add name=opt82-hotspot-sync owner=admin policy=read,write,test source={
|
|
# Add bypass for any bound lease with Option 82
|
|
/ip dhcp-server lease foreach={
|
|
:if ($activeAgentRemoteId != "" && $status = "bound") do={
|
|
:if ([/ip hotspot ip-binding find where address=$activeAddress server=hotspot1 mac-address=$activeMacAddress] = "") do={
|
|
/ip hotspot ip-binding add address=$activeAddress mac-address=$activeMacAddress server=hotspot1 to-address=$activeAddress type=bypassed
|
|
:log info "opt82-poll: bypassed $activeMacAddress / $activeAddress"
|
|
}
|
|
}
|
|
}
|
|
# Remove bypasses for IPs that no longer have any bound lease
|
|
/ip hotspot ip-binding foreach={
|
|
:if ($server = "hotspot1" && $mac-address != "") do={
|
|
:if ([/ip dhcp-server lease find where activeAddress=$address] = "") do={
|
|
/ip hotspot ip-binding remove $.
|
|
:log info "opt82-poll: removed bypass for $mac-address / $address (no lease)"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/system scheduler add name=opt82-hotspot-sync interval=10s on-event="/system script run opt82-hotspot-sync" policy=read,write,test
|