Page 1 of 1
Scrip for relase/renew IP DHCP Client
Posted: Fri Apr 20, 2012 10:42 am
by Piplfox
Hi, I need a sript that will ping some Internet address or dns (let say 8.8.8.8 ) and if no replay for 5 min release WAN address and renew it. I have dynamic address on MT WAN from Internet provider cable modem. Is there any similar solution, cose sometimes Internet stops working and all I have to do is renew IP address on DHCP clinet on WAN interface.
Re: Scrip for relase/renew IP DHCP Client
Posted: Fri Apr 20, 2012 7:22 pm
by c0d3rSh3ll
this script
:if ( [/ping 8.8.8.8 interface=wan count=6 ] = 0 ) do={/ip dhcp-client renew wan}
and scheduler for the script with interval 5 min
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 21, 2012 4:51 am
by jandafields
Hi, I need a sript that will ping some Internet address or dns (let say 8.8.8.8 ) and if no replay for 5 min release WAN address and renew it. I have dynamic address on MT WAN from Internet provider cable modem. Is there any similar solution, cose sometimes Internet stops working and all I have to do is renew IP address on DHCP clinet on WAN interface.
Make the script disable and then enable the interface. That should cause it to renew the DHCP.
Re: Scrip for relase/renew IP DHCP Client
Posted: Thu May 03, 2012 9:57 am
by Piplfox
this script
:if ( [/ping 8.8.8.8 interface=wan count=6 ] = 0 ) do={/ip dhcp-client renew wan}
and scheduler for the script with interval 5 min
Thanks mate this work like a charm.
Re: Scrip for relase/renew IP DHCP Client
Posted: Tue Jun 05, 2012 3:01 am
by givemesam
Hi!
this is what i am looking for but i am a noob for scripting.
it would be great if someone could make this a bit clearer for me.
I need a script that will renew the dhcp client on ether1-gateway (i assume 'wan' was a label) if it can not ping out to 8.8.8.8 x times in 15 seconds.
Ideally you can give me instructions on how to do this via winbox, box by box.
Thank you
Sam
ps. disable / enable will work too
pps. i tried doing it with the script above, chaning the label and the the times, but the script would run every 15 seconds regardless, and it was not doing what i wanted. I assume you have to paste the script into the scheduler.
Is there a way to make this so it is triggered? and not run every 15 seconds? (dont know what is the best way to accomplish this task. Actual problem is that if the parent DHCP server is reset, MT doesnt get renewal due to elapsed boot time of dhcp server. so i need to have something that will do a kind of health check)
Re: Scrip for relase/renew IP DHCP Client
Posted: Wed Oct 10, 2012 9:21 am
by faustomorales
Upgrade your routerOs to 5.10 or higher to fix this bug.
What's new in 5.10 (2011-Dec-09 11:49):
*) snmp - provide extended interface statistics when availabe;
*) dhcpv6 client - use link-scoped multicast address;
*) dhcp client - renew dhcp lease on ethernet link up event;
*) ipv6 gre tunnel added (/interface gre6) supports ip and ipv6 encapsulation;
*) ip gre tunnel supports ipv6 encapsulation;
*) allow setting bigger trafflow cache;
*) improved RB1200 stability when using ether9,ether10;
*) fixed RB1200 stability issues when using crypto hardware acceleration;
Re: Scrip for relase/renew IP DHCP Client
Posted: Wed May 07, 2014 1:47 pm
by ddrazen
I'm connected to free hotspot.I need to accept EULA to surf, but when 30 min pass I need to release wan to connect again and accept Eula again.I can only ping 1.1.1.1 after accepting eula in browser.Renew wan doesn't work.I tried this script with removing renew and put release but it didn't work,I must mannualy click release to again connect and accept eula.What kind of script would help with this?
I have routerboard 411r with 6.7 ROS.
Re: Scrip for relase/renew IP DHCP Client
Posted: Sun May 11, 2014 3:31 am
by rextended
It's a free hotspot, do not abuse the service
![Surprised :o](./images/smilies/icon_surprised.gif)
Re: Scrip for relase/renew IP DHCP Client
Posted: Tue May 13, 2014 11:31 am
by plisken
Is that the fully script?
this script
:if ( [/ping 8.8.8.8 interface=wan count=6 ] = 0 ) do={/ip dhcp-client renew wan}
and scheduler for the script with interval 5 min
Thanks mate this work like a charm.
Re: Scrip for relase/renew IP DHCP Client
Posted: Sun Aug 31, 2014 10:47 pm
by dangucci
Hi guys, I would like to know how to make a script to check if ppp-out1 interfaces's ip falls in an ip range which is, the first octet
must be 10, second octet 43 , third octet greater than 128 .. eg 10.43.129.23
If ip addres of ppp-out1 falls within the range then
script should exit
but if ip addres of ppp-out1 doesnt fall within the range then script should execute the command
interface ppp-client disable ppp-out1
interface ppp-client enable ppp-out1
this would be on a scheduled task to be run every 10 seconds
Thank you so much for all your help!!!!!
Re: Scrip for relase/renew IP DHCP Client
Posted: Mon Dec 04, 2017 5:22 am
by JHOELIT
I share these useful examples
/ ip dhcp-client release 0
/ ip dhcp-client release [find interface =ether1]
It is valid for (release) or (renew)
God bless you
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Jun 09, 2018 8:58 am
by jos7890106
try with the previous script but it gives me an error I think, try to modify it to my settings but it just gave another error. I need help, I am new and I do not know where to find the solution, if they could explain me. Thank you.
this is the error ke gives me now
[admin @ HTC Desire 626s]>: if ([/ ping ng 8.8.8.8 interface = wan count = 6] = 0) do = {/ ip dhcp-client renew wlan 1}
expected end of command (line 1 column 19)
[admin @ HTC Desire 626s] >>
[admin @ HTC Desire 626s] >>: if ([/ ping ng 8.8.8.8 interface = wlan 1 count = 6] = 0) do = {/ ip dhcp-client renew wlan 1}
expected end of command (line 1 column 19)
[admin @ HTC Desire 626s] >>: if ([/ ping ng 181.225.231.120 interface = wlan 1 count = 6] = 0) do = {/ ip dhcp-client renew wlan 1}
expected end of command (line 1 column 19)
[admin @ HTC Desire 626s] >>
Re: Scrip for relase/renew IP DHCP Client
Posted: Fri Feb 08, 2019 11:54 am
by Shestakov
try without "ng"
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 4:43 pm
by dcavni
this script
:if ( [/ping 8.8.8.8 interface=wan count=6 ] = 0 ) do={/ip dhcp-client renew wan}
and scheduler for the script with interval 5 min
Let me bring this old topic up a bit.
I have the same problem on one cable modem. If you restart the modem, Mikrotik doesn't let go of the WAN DHCP IP and the internet isn't working until you restart Mikrotik or use DHCP Release button. Where can i set this rule or something similar in Mikrotik, so that it tries to ping some IP and if no response it renews DHCP lease?
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 4:53 pm
by rextended
Simply schedule it on boot with interval of 5 min
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 4:55 pm
by dcavni
Can you please give me a bit more detailed instruction where to put the script? I'm completly new at scripts. I also looked at netwatch, can this be used in any way?
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 4:59 pm
by rextended
What you can do, if you do not have experience, simply put 8.8.8.8 inside System / Watchdog / Watch Address
With default values, if 8.8.8.8 stop responding for more than 1 minute, the device reboot.
But after reboot, the OS wait 5 minutes before check again, and so on.
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 5:09 pm
by eldoncito2019
Try this friend
:if condition=([/ping 1.1.1.1 count=6] =0) do={/ip dhcp-client release [ find interface ="ether1"]}
I hope it helps you
EL DONCITO.
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 5:15 pm
by dcavni
Try this friend
:if condition=([/ping 1.1.1.1 count=6] =0) do={/ip dhcp-client release [ find interface ="ether1"]}
I hope it helps you
EL DONCITO.
Please only tell me, where should i put this script?
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 5:18 pm
by eldoncito2019
In scheduler and give it a time of 10 seconds for the script to run.
"ether1" is your interface that receives internet, with what name do you have it?
EL DONCITO.
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 5:20 pm
by dcavni
Ok, thank you very much for help. Will do it as soon as i get to computer.
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 5:29 pm
by rextended
Do it correctly, this do not need to specific the interface.
:if ([/ping 1.1.1.1 count=10] = 0) do={/ip dhcp-client release [find]}
Do not execute ping too often, or you risk to be putted sooner or later on blacklist...
Re: Scrip for relase/renew IP DHCP Client
Posted: Sat Apr 23, 2022 6:46 pm
by dcavni
Do it correctly, this do not need to specific the interface.
:if ([/ping 1.1.1.1 count=10] = 0) do={/ip dhcp-client release [find]}
Do not execute ping too often, or you risk to be putted sooner or later on blacklist...
Ok, now i set this:
:if ([/ping 1.1.1.1 count=5] = 0) do={/ip dhcp-client release [find]}
in system/schedule
admin@MikroTik] > /system/schedule print
Columns: NAME, START-DATE, START-TIME, INTERVAL
# NAME START-DATE START-TIME INTERVAL
0 DHCP Renew apr/23/2022 15:32:24 59m
i think count=5 should be enough and interval is 59 minutes.
Thank you all for help.