Setting BGP Prepend

Hey guys,

I’ve never really had much luck with using Route Filter’s and Policy Filters to set preferences with BGP routes.

So I wanted to find how to achieve my goal.

So I have 2 uplinks from my ISP, both running at 1Gbps. Each link goes into a separate router. One is a Mikrotik x86 the other is my VyOS box.

What I want to be able to do, is set the BGP prepend on my advertised routes to my ISP, so that I can effectively define a “primary” router between the two. This is so I can fail over to the VyOS box from the Mikrotik box, and have the VyOS box as the preferred route. So I can decommission the Mikrotik box without losing connectivity.

Assuming your topology looks something like this:

      INTERNET
    /            \
   /              \
Circuit A          Circuit B
   |               |
   |               |
mikrotik        VyOS
    \             /
     \           /
   Internal_Network

The BGP AS prepend should be configured on the mikrotik router. This will cause it to look like a ‘worse’ path then the VyOS router. BGP treats AS path lilke a ‘hop count’ . The major network vendors have some differences in BGP path selection, but if left at default the shortest AS path will generally be preferred.

1 Like

Hi @chrisrg

Yep! That’s exactly what I’ve done. For the mean time. The problem I have, is that I’m going to be removing the Mikrotik, and then replacing it with another VyOS instance. So the problem that I’ll be having then, is needing to do the Prepend for one of the VyOS routers.

I know there is another option where I can set the Local Preference, and then hopefully my ISP will respect that.

What I’m trying to achieve is a way to manually direct traffic for the times where I want to move or change or reboot routers.

With the goal of ‘manually redirecting traffic during change actions’ in mind. I usually manually shutdown the BGP peer on the router that I do not wish to process traffic. This is very graceful as the surviving peer with begin to carry the load. When you notice no traffic traversing the ‘admin down peer’ (usually 5 minutes or less), start the change action.

The process of manually shutting down a bgp peer is different per vendor.

Regarding as-prepend and local-preference consider this:

as-prepend is used to affect how an AS receives traffic.
as-prepend is a bit counter intuitive as it’s configured facing the peer that we do not wish to receive traffic from.

local-preference is used to affect how an AS transmits traffic.
local-preference is increased for the peer that we wish to transmit traffic to.

Hi Chrisg could you possibly share the syntax of how you accomplished this please. I am having an issue where the command is erroring out. Thank you in advance.

What are you trying to achieve? Might be able to share some configs with you.