Setting "distance" for BGP routes/peers



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 - 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 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?


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


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)


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


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.