Community discussions

MikroTik App
 
eldoncito2019
Member Candidate
Member Candidate
Topic Author
Posts: 288
Joined: Fri Jun 14, 2019 1:07 pm

Script in IP DHCP Client

Wed Sep 28, 2022 4:06 pm

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
You do not have the required permissions to view the files attached to this post.
EL DONCITO.
 
Sob
Forum Guru
Forum Guru
Posts: 8959
Joined: Mon Apr 20, 2009 9:11 pm

Re: Script in IP DHCP Client

Wed Sep 28, 2022 10:00 pm

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).
Come on people, do you really have to quote full posts? It's annoying and in most cases useless.
 
eldoncito2019
Member Candidate
Member Candidate
Topic Author
Posts: 288
Joined: Fri Jun 14, 2019 1:07 pm

Re: Script in IP DHCP Client

Wed Sep 28, 2022 10:50 pm

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





EL DONCITO.
EL DONCITO.
 
Sob
Forum Guru
Forum Guru
Posts: 8959
Joined: Mon Apr 20, 2009 9:11 pm

Re: Script in IP DHCP Client

Wed Sep 28, 2022 11:15 pm

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.
Come on people, do you really have to quote full posts? It's annoying and in most cases useless.
 
eldoncito2019
Member Candidate
Member Candidate
Topic Author
Posts: 288
Joined: Fri Jun 14, 2019 1:07 pm

Re: Script in IP DHCP Client

Wed Sep 28, 2022 11:30 pm

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.
EL DONCITO.
 
Sob
Forum Guru
Forum Guru
Posts: 8959
Joined: Mon Apr 20, 2009 9:11 pm

Re: Script in IP DHCP Client

Thu Sep 29, 2022 12:05 am

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?
Come on people, do you really have to quote full posts? It's annoying and in most cases useless.
 
eldoncito2019
Member Candidate
Member Candidate
Topic Author
Posts: 288
Joined: Fri Jun 14, 2019 1:07 pm

Re: Script in IP DHCP Client

Thu Sep 29, 2022 12:09 am

Just to know if it was possible anything else




EL DONCITO.
EL DONCITO.
 
eldoncito2019
Member Candidate
Member Candidate
Topic Author
Posts: 288
Joined: Fri Jun 14, 2019 1:07 pm

Re: Script in IP DHCP Client

Sat Oct 01, 2022 12:53 pm

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.
EL DONCITO.

Who is online

Users browsing this forum: No registered users and 5 guests