BGP Best Path Selection

In BGP, a router receives prefix announcements via eBGP. If you are multi-homed or peer, you will receive announcements for one and the same prefix from multiple sources. Out of these multiple announcements, a router has to select one announcement as best. This best prefix announcement will then be used for routing and also propagated further (for simplicity we will not look at BGP multipath where more than one announcement is selected).

The decision which prefix announcement is best has to meet the following criteria:

  • Only one single path for each prefix is needed (and wanted)
  • The decision has to be based on attributes of the BGP announcement
  • The decision has to be be deterministic (with the same parameters, the decision is always the same)

Below you can find an example of the BGP routing algorithm according to RFC4271 that explains how your router chooses which prefix to take.

Your router*:

  1. Checks if next hop is reachable
  2. Chooses route with the highest Local Preference (this is where you prefer peering over upstream)
  3. Prefers the route with the shortest AS path
  4. Prefers the route with the lowest origin attribute
  5. Prefers the route with the lowest MED value
  6. Prefers routes received from eBGP over iBGP
  7. Prefers the nearest exit from your network (in terms of your internal routing protocol)
  8. Implementation dependent: Prefers older (= more stable) routes
  9. Prefers routes learned from the router with lower router ID
  10. Prefers routes learned from the router with lower IP address
*most important rules are bold; implementations are vendor-specific

The router starts selecting a best path by checking if the BGP announcement is valid. Only paths where the next hop is reachable are taken into consideration; if the next hop is not reachable, the announcement is discarded.

To have the criteria at hand, you can download the DE-CIX Academy Knowledgecard on BGP Routing Algorithm here. Or meet us at one of our events and get a printed copy. 

DE-CIX Academy Knowledge Card