Page 1 of 1

Script to exchange dynamic ip gateway in IP / Routes

Posted: Sun May 27, 2018 6:36 am
by severinoeuclides
Hello there everyone of the forum, I am new and would like a help on a Script

I'm trying to find a script to automatically change the dynamic ip of my carrier, where I want to capture the gateway of a rule in IP / DHCP Client and update the route gateway automatically !!

I could leave it there normal, but there is issue and I have 2 internet links and I want to put the rules of routes and execute this script with there rule of sheduler dripping to the dns ip of google 8.8.8.8 if the link signal falls of the operator the script will run automatically, updating the gateway and there is a route !!

Re: Script to exchange dynamic ip gateway in IP / Routes

Posted: Sat Jun 09, 2018 7:15 am
by severinoeuclides
I've tried with this script but it does not run at all, can someone help me in this matter !!

:global newgw [/ip dhcp-client get [find interface="ether4" ] gateway ]
:global activegw [/ip routes get [/ip routes find comment="ether4"] gateway ]
:if ($newgw != $activegw) do={
/ip routes set [find comment="ether4"] gateway=$newgw
/ip routes set [find comment="ether4-Wan routing gateway"] gateway=$newgw
}

Re: Script to exchange dynamic ip gateway in IP / Routes

Posted: Mon Sep 24, 2018 6:13 pm
by ekarin
I have seen your issue that is quite similar to my current issue.
Please have a look at the followingpost.
viewtopic.php?f=9&t=139597&p=688423#p688423

Hopefully it helps.