Community discussions

MikroTik App
 
jfreak53
newbie
Topic Author
Posts: 45
Joined: Fri Oct 04, 2019 3:18 am

Auto Fail over BGP Peers and ports

Mon Nov 06, 2023 9:19 pm

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!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Auto Fail over BGP Peers and ports

Tue Nov 07, 2023 11:07 am

Why only use scripts, when Netwatch exists?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10248
Joined: Mon Jun 08, 2015 12:09 pm

Re: Auto Fail over BGP Peers and ports

Tue Nov 07, 2023 12:28 pm

Or even better, BFD. It was made for this purpose.
 
DarkNate
Forum Guru
Forum Guru
Posts: 1017
Joined: Fri Jun 26, 2020 4:37 pm

Re: Auto Fail over BGP Peers and ports

Tue Nov 07, 2023 12:51 pm

Very few people are really qualified to work with dynamic routing protocols. Maybe MikroTik should make more in-depth content on these.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Auto Fail over BGP Peers and ports

Tue Nov 07, 2023 1:39 pm

Or even better, BFD. It was made for this purpose.
When is really ready and works...
 
DarkNate
Forum Guru
Forum Guru
Posts: 1017
Joined: Fri Jun 26, 2020 4:37 pm

Re: Auto Fail over BGP Peers and ports

Tue Nov 07, 2023 2:25 pm

Or even better, BFD. It was made for this purpose.
When is really ready and works...
Works fine on v7.11.2. No problems here for months/weeks now. Even cross-vendor.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10248
Joined: Mon Jun 08, 2015 12:09 pm

Re: Auto Fail over BGP Peers and ports

Tue Nov 07, 2023 2:52 pm

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

Who is online

Users browsing this forum: Google [Bot] and 8 guests