Setting "distance" for BGP routes/peers

bgp

#1

We are trying to figure out if there is a way to set “distance” for BGP learned routes (either for specific routes, or all routes learned from a peer).

Alternatively, I would be happy to see if there are other options to achieve the following:

Assume we have a router which is running 2 eBGP sessions which receive the same prefix from both peers (let’s say 192.0.2.0/24) - Each peer is associated with a different interface (let’s say eth0 and eth2).
We also have another interface, eth1, which would have a static route for 192.0.2.0 pointed at it.

We would like to set the preference for the route selection to look like:
eth0: priority 1
eth1: priority 2
eth2: priority 3

So within BGP, we could set local-pref to some priority-based value, which will resolve between the eth0 and eth2 paths, but then the selected route would have the default eBGP distance. This will now be compared with the static route’s distance pointing to eth1.

What I am trying to achieve is being able to control the distance of the BGP route when it is being compared with the static route.

Is this supported today?
Any other ideas on how this can be achieved?


#2

Is setting a higher administrative distance for the static route out of the question?


#3

what I am basically looking for is a way to set administrative distance to different BGP routes to different values.
Some BGP learned routes may be better than the static route and others could be worse… Depending on the specific setup (trying to design a generic feature)


#4

Would path pre-pending work for your requirement ? This should allow you to influence based on the incoming neighbour.

https://wiki.vyos.net/wiki/Routing_policy


#5

Unfortunately, no… Path Prepending will influence the BGP best path selection.
What I am looking for is a way to set the distance of a BGP routes when it is being installed in the local RIB.