Script in IP DHCP Client

Cheers,
I have this script running in /system scheduler and it does it very well,


:if ([/ping 1.1.1.1 count=6] = 0) do={/ip dhcp-client release [find]}

My question is how do I put it in IP DHCP Client, I can’t find how to do it.

IP DHCP CLIENT.jpg
Thanks for your help.




EL DONCITO

And what are your expectations? The script makes sense when run periodically from scheduler. But DHCP lease script is executed only on DHCP events (acquire address, lose address).

I want it to do the same but set to IP DHCP Client





EL DONCITO.

And that should be better how exactly? Or how should it even work? If you run it from scheduler, it runs every X seconds/minutes/hours, whatever interval you used. If you add it to DHCP client, it will run once for each event. It won’t be the same at all.

I would like it to be released when the IP that my isp delivers is down, do you understand me?

Can be done like this?



EL DONCITO.

My guess is that it’s not possible. If you need to check it repeatedly, then script running once is clearly not a best place for it. Unless it would accept endless loop, but it still wouldn’t be good, because you’d need to synchronize it with other DHCP events that you don’t control.

Back to beginning, what’s wrong with scheduler when you say that it works well?

Just to know if it was possible anything else




EL DONCITO.

Would this be the endless loop?

:local stopRouterRun false
:do {
:delay 10s
} while=(!$stopRouterRun)

would there be something like this?

:local stopRouterRun false
:do {
/ip dhcp-client
:if ([/ping 1.1.1.1 count=6] = 0) do={/ip dhcp-client release [find]}
:delay 10s
} while=(!$stopRouterRun)

EL DONCITO.

Netwatch…

/tool netwatch add  host=1.1.1.1  timeout=15s down-script="/ip dhcp-client release numbers=0" comment="Monitor Cloudflare"

Obviously changing “numbers=0” for whatever interface this is on, and the timeout to what suits. You can also Log errors as you see fit. This is at a 1 second interval by default.

You can also write this to be added when you dhcp is bound - and then also remove when unbound (important). As to how - you’ll have to research that for yourself (I recommend making one that suits - exporting and adding to dhcp-client script to simplify the process). Also you can do finds to get the variables you need - but I am deep in that hole ATM and have nothing to offer (apart from a search for comment is mostly doable).

V7 has more options for netwatch.

NO never use numbers.


NO for same reason on previous posts

\




If work do not change.

Endless loops are one idiocy, till exist the scheduler or netwatch.