DHCP client script execution

I see the DHCP client can execute a script. I cannot seem to make the script execute - under what circumstances should this trigger? I assumed a manual release would trigger the script. Or any change in the DHCP client status - any thoughts? Thanks.

I’ll report what Wiki says:

Script that will be executed after lease is assigned or de-assigned. Internal “global” variables that can be used in the script:
leaseBound - set to “1” if bound, otherwise set to “0”
leaseServerName - dhcp server name
leaseActMAC - active mac address
leaseActIP - active IP address

Script is triggered everytime a lease is bound, offered, busy, unbound etc.
You can use leaseBound variable to make script do something when a client correctly gets an IP from DHCP and when he lose it.
For example I made a script that, when a client is bound, it takes IP, checks in neighbor if the client is MK and if yes it adds a dynamic dst-nat rule to connect to, with client MAC address as comment.
When the lease is released, the script disable that dynamic NAT, adding in the comment date and time.

With this script I can install N hAP and I don’t need to NAT them.

(red)

Thanks for this.
does this script run automatically at startup?

I’m having some trouble getting this to work on a hAP ac2. I will add the variable and see if I get a different result.

Thank you for your help.

Is there any way to see these values via CLI in the terminal windows to get there current status?

I don’t know, but I think not.
They’re variable only for DHCP server, so maybe they don’t have a global scope, they’re like :local.
The script doesn’t run on startup, but when a client makes DHCP requests, so yes, when you reboot it is ready to be triggered by a client.

Why interface change status can’t change dhcp client status? I have example, then I connect Mikrotik (which had ip dhcp received) to switch, witch has ip-spoofing enabled, Mikrotik sends dhcp request, not discover. In this situation ip-spoofing table do not add this ip. Manually connect to Mikrotik and press release or reboot router is not a good option. Disconnecting interface could make dhcp-client to start from dhcp-discover. Is it possible to make this with script for now and hope for routeros version with this option?

No it’s not, i’ve tried it.. It’s only triggered on a bound event