BGP - attributes and path selection
In a typical BGP topology, BGP routers will often receive information about multiple paths to the same destination. Similar to IGPs such as RIP, EIGRP, and OSPF, we need to select the best path to each destination.
IGPs select the path with the lowest metric. BGP however, selects the best path based on a list of attributes. On the Internet, it’s more important that you have granular control over how you forward your traffic and to which autonomous systems you send traffic, rather than just going for the shortest path based on a metric.
When a BGP router receives information about multiple paths to a particular destination, it will go through the following attributes, in this order, to determine which is the best path. If there is a tie on a particular attribute, it examines the next attribute down the line. Here is the list of attributes used by BGP:
- Weight: This is a Cisco-specific attribute. It's locally significant and not advertised to neighboring routers. Higher weight values have preference over lower ones.
- Local Preference: This is the second attribute checked, and it's more significant than most others as it influences outbound routing decisions. Like Weight, it is not advertised to neighboring routers.
- Locally Originated: The BGP router prefers the routes that it has locally originated via a network or aggregate BGP subcommand, or through redistribution from an IGP.
- AS Path: This is one of the most important attributes. BGP prefers the path with the shortest AS Path.
- Origin: The origin attribute defines how BGP learned about a particular route. The values can be IGP, EGP, or Incomplete. BGP prefers IGP over EGP and EGP over Incomplete.
- MED (Multi-Exit Discriminator): The MED is a hint to the external neighbors about the preferred path into an AS when there are multiple entry points into the AS. A lower MED is preferred over a higher one.
- eBGP over iBGP Paths: If it comes to this step, BGP will prefer eBGP paths over iBGP paths.
- Shortest IGP Path to the BGP Next Hop: BGP prefers the path that the local router has the shortest IGP path to.
- Oldest Path: If all other attributes are the same, BGP prefers the oldest path.
- Router ID: If all else is equal, the BGP router with the lowest router ID is preferred.
- Neighbor Type: If the Router ID is the same, then BGP prefers the path through the neighbor with the lowest IP address.
Note that BGP attributes can be manipulated to influence path selection in a way that fulfills specific network requirements.
Links to this page:
- BGP - Accumulated IGP metric
- BGP - MED vs AS Prepending
- BGP - Network Layer Reachability Information (NLRI)
- BGP - Why is MED non-transitive
- BGP - oldest path attribute
- BGP - transitive and non-transitive attributes
- BGP AS_PATH when using aggregate-address
- BGP Attributes - route map direction
- BGP Default local preference and its appearance in the BGP table
- BGP Equal cost multipath
- BGP Extended Community
- BGP Influencing incoming traffic
- BGP Influencing outgoing traffic
- BGP Load balancing
- BGP advertises only the best path by default
- BGP and route tagging
- BGP applying route maps to prefixes
- BGP how MED attribute is compared
- MPLS - Using the BGP Allow-AS in feature