Script to change disconnect Eth interface to connected one

I am trying to locate a script to automatically switch Ethernet1 connection to Ethernet2 when one of two fails and/or loses connection. We have (2) T-1’s connected to the router. I can manually disable one and it automatically picks up the next connected T-1. The issue is I have to manually do this from my desktop on the network. I was told there is a script to do this automatically. Thanks for your help..

Add 2 default routes, the first with distance 1 and other with distance 2.

When the route with distance 1 is not reachable the router use the second route with distance 2.

Send from my mobile phone using Tapatalk.

+1… if you don’t want to do it that way I have a script I could modify to do that if you want me to post it… Just let me know.

Thank you very much for responding.. Yes, I would greatly appreciate you posting the script. I am very “green” to this router. Its intimidating at times because so many of us rely on it at my office. Thanks again!!

Yes pls post!! Thanks!!

You need routing marks so it can direct the pings out of the specific links… You can modify it as you want it.
#########################################################

Variables

#########################################################
:global pingFailuresWAN01
:global WState01

:global pingFailuresWAN02
:global WState02

:local pingTarget 8.8.8.8
:local failureThreshold 3
:local pingResult

#########################################################

WAN01 - Interface = ether1

#########################################################
:set pingResult [ping $pingTarget count=1 interface=ether1 routing-table=WANID01]
:if ($pingResult = 0) do={
:if ($pingFailuresWAN01 < ($failureThreshold+2)) do={
:set pingFailuresWAN01 ($pingFailuresWAN01 + 1)
:if ($pingFailuresWAN01 = $failureThreshold) do={
:set WState01 0
/ip firewall address-list add comment=“WANID01” list=“DeadLinkDetector” address=“0.0.0.1”
/ip firewall mangle disable [/ip firewall mangle find comment=“PCC_WANID01”]
}
}
}
:if ($pingResult = 1) do={
:if ($pingFailuresWAN01 > 0) do={
:set pingFailuresWAN01 ($pingFailuresWAN01 - 1)
:if ($pingFailuresWAN01 = ($failureThreshold -1)) do={
:set WState01 1
/ip firewall address-list remove [find list=“DeadLinkDetector” address=“0.0.0.1”]
/ip firewall mangle enable [/ip firewall mangle find comment=“PCC_WANID01”]
}
}
}

#########################################################

WAN02 - Interface = ether2

#########################################################
:set pingResult [ping $pingTarget count=1 interface=ether2 routing-table=WANID02]
:if ($pingResult = 0) do={
:if ($pingFailuresWAN02 < ($failureThreshold+2)) do={
:set pingFailuresWAN02 ($pingFailuresWAN02 + 1)
:if ($pingFailuresWAN02 = $failureThreshold) do={
:set WState02 0
/ip firewall address-list add comment=“WANID02” list=“DeadLinkDetector” address=“0.0.0.2”
/ip firewall mangle disable [/ip firewall mangle find comment=“PCC_WANID02”]
}
}
}
:if ($pingResult = 1) do={
:if ($pingFailuresWAN02 > 0) do={
:set pingFailuresWAN02 ($pingFailuresWAN02 - 1)
:if ($pingFailuresWAN02 = ($failureThreshold -1)) do={
:set WState02 1
/ip firewall address-list remove [find list=“DeadLinkDetector” address=“0.0.0.2”]
/ip firewall mangle enable [/ip firewall mangle find comment=“PCC_WANID02”]
}
}
}

Can anyone tell me how to set the timeout on the ping test. My backup ISP is very slow and gives > 3s ping times sometimes so even though it may be working, the script thinks it is not and increases the route distance.