Auto Fail over BGP Peers and ports

I’ve got two fiber ports coming into our main router, in round-robin mode for fail-over as well. All that works great. But I’m trying to configure it to auto-fail over in case of port A or B line being down in the middle of the night. This script is what I have, will this work or is there a better way to do this? We are using BGP sessions so need to make sure it takes BGP peers down and stops routing through the downed port.

:local wan1Gateway6 "ip1"
:local wan1Gateway4 "ip2"
:local wan2Gateway6 "ip3"
:local wan2Gateway4 "ip4

:local wan1Gateway "sfp-sfpplus1"
:local wan2Gateway "sfp-sfpplus2"

:local wan1Up [/ping $wan1Gateway4 count=2]
:local wan2Up [/ping $wan2Gateway4 count=2]

:if ($wan1Up = 0) do={
  /ip route set [find gateway=sfp-sfpplus1] disabled=yes
  /routing bgp peer set [find remote-address=$wan1Gateway4] disabled=yes
  /routing bgp peer set [find remote-address=$wan1Gateway6] disabled=yes
}

:if ($wan2Up = 0) do={
  /ip route set [find gateway=sfp-sfpplus2] disabled=yes
  /routing bgp peer set [find remote-address=$wan2Gateway4] disabled=yes
  /routing bgp peer set [find remote-address=$wan2Gateway6] disabled=yes
}

:if ($wan1Up > 0) do={
  /ip route set [find gateway=sfp-sfpplus1] disabled=no
  /routing bgp peer set [find remote-address=$wan1Gateway4] disabled=no
  /routing bgp peer set [find remote-address=$wan1Gateway6] disabled=no
}

:if ($wan2Up > 0) do={
  /ip route set [find gateway=sfp-sfpplus2] disabled=no
  /routing bgp peer set [find remote-address=$wan2Gateway4] disabled=no
  /routing bgp peer set [find remote-address=$wan2Gateway6] disabled=no
}

Also, if this is the best way to do it, I don’t like waiting one minute for it to fail, would 30 seconds be too short of a time to check it and run the script? We are using a CCR1072 FYI in ROS 6.48.6. Thanks!

Why only use scripts, when Netwatch exists?

Or even better, BFD. It was made for this purpose.

Very few people are really qualified to work with dynamic routing protocols. Maybe MikroTik should make more in-depth content on these.

When is really ready and works…

Works fine on v7.11.2. No problems here for months/weeks now. Even cross-vendor.

Indeed. And he has 6.48.6 so it isn’t an issue.