BGP Configuration Guide for Cisco 8000 Series Routers, Cisco IOS XR Releases

PDF

How BGP path selection works

Want to summarize with AI?

Log in

Overview

Details how BGP path selection operates, explaining the sequential steps and criteria used to determine the preferred routing path for network traffic.

BGP path selection occurs whenever multiple valid routes exist to the same destination. The router applies a series of steps, taking into account both protocol defaults and administrator-configured attributes to determine which path is installed in the routing table.

Summary

The key components involved in the process are:

  • BGP router: A router that evaluates and compares multiple available routes using protocol-defined criteria.

  • Configured attributes: Attributes that include weight, local preference, AS path, origin, MED, and community values, which influence path selection at each stage.

  • BGP neighbors: External (eBGP) or internal (iBGP/ confederation), whose routes are candidates for selection.

When a router receives multiple BGP routes for the same destination, it selects the best path by first discarding invalid paths and preferring those with lower pre-bestpath cost communities if configured. It then compares attributes like weight, local preference, and whether the path is locally originated. Next, it evaluates AS path length, origin type, and MED among paths from the same AS. Advanced criteria favor eBGP-learned paths, lower IGP metrics to the next hop, and lower IP cost communities. If still tied, it uses tie-breakers such as lowest router ID, shortest cluster list, and lowest neighbor IP address. If all attributes tie, the current best path is retained until a change triggers re-selection.

Workflow

These stages describe the BGP path selection process.

  1. The router receives multiple BGP route advertisements for the same destination from different peers.
  2. The router performs preliminary checks:
    • removes invalid paths, such as those with unreachable next hops or exceeded MED values.
    • prefers the path with the lowest pre-bestpath cost community value.
  3. The router compares attribute-based preferences and selects as follows:
    • Weight: chooses the path with the highest weight.
    • Local preference: prefers the path with the highest local preference value.
    • Locally originated path or aggregate: prefers any paths that are locally originated or created with the network or aggregate-address commands.
  4. The router evaluates path characteristics:
    • AS path length: selects the path with the shortest AS path (unless the relevant configuration is set to ignore AS path).
    • Origin type: chooses the path with the lowest origin type (IGP over EGP over Incomplete).
    • Multi-Exit Discriminator (MED): selects the one with the lowest MED among paths from the same neighboring AS.
  5. The router applies advanced criteria:
    • eBGP over iBGP: prefers a path learned via eBGP over those learned via iBGP or confederation peers.
    • IGP metric to next hop: chooses the path with the lowest IGP metric to the BGP next hop.
    • IP cost community: if present, selects the path with the lowest IP cost community value.
  6. The router uses final tie-breakers when paths are still equal:
    • Router ID: selects the path received from the peer with the lowest router ID (using originator ID if available).
    • Cluster list length: prefers the path with the shortest cluster list.
    • Neighbor IP address: As a last resort, chooses the path from the peer with the lowest neighbor IP address (locally generated paths are considered to have IP address 0).
  7. If all these attributes result in a tie, the router maintains the current best path until a configuration change forces re-selection.

Example of path comparison order

Suppose a router receives three routes (A, B, C) to the same prefix. The router compares routes in sequence, stopping at the first attribute where one route is superior. The first attribute to break the tie determines the best path.