Summary of BGP Path Selection and Attributes
BGP Path Selection and Attributes: The Ultimate Guide
Introduction
BGP (Border Gateway Protocol) selects a single best path to each prefix from multiple candidate routes using an ordered list of attributes. Understanding the BGP path selection process helps you predict which path a router will install in its routing table and why certain routes are preferred over others.
Definition: The BGP path selection algorithm is an ordered sequence of attribute comparisons that BGP uses to choose one best path when multiple paths to the same prefix exist.
How the Path Selection Works (Overview)
BGP evaluates attributes in a fixed order, starting with the highest-priority attribute and moving down until a single best path is identified. If attributes are equal at a step, BGP continues to the next attribute. If all attributes tie, BGP uses the neighbor IP address as the final tiebreaker.
Ordered Steps (high-level)
- Weight (highest priority on Cisco routers) — local to the router
- Local Preference — used within an AS
- Locally originated routes — prefer a route the router originated itself
- AS Path length — prefer the shortest AS path
- Origin code — prefer IGP over EGP over INCOMPLETE
- MED (Multi-Exit Discriminator) — prefer the lowest MED
- eBGP over iBGP — prefer externally learned paths
- IGP metric to BGP next hop — prefer lowest IGP cost to reach next hop
- Oldest path — prefer the path received first
- BGP router ID — prefer lowest neighbor router ID
- Neighbor IP address — prefer lowest neighbor IP as final tiebreaker
Definition: The BGP neighbor router ID is the BGP identifier for a peer, usually the highest IP address on the router or a manually configured value.
Detailed Attribute Breakdown
Weight
- Cisco-proprietary attribute, configured locally on a router.
- Higher weight is preferred.
- Default weight is 0 for routes not originated locally.
Definition: Weight is a local, non-propagated attribute influencing path selection only on the router where it is configured.
Local Preference (LocPrf)
- Advertised between iBGP peers in the same AS.
- Higher local preference is preferred.
- Default value is 100 unless changed.
Definition: Local Preference is an attribute indicating preference for exit points from the AS; higher values are more preferred.
Locally Originated Routes
- Routes the router itself injected into BGP (network, redistribution, aggregate) have next hop 0.0.0.0.
- Prefer locally originated BGP routes over those learned from peers.
AS Path Length
- Prefer shorter AS path (fewer AS numbers in the path).
- Example: AS path
1 2 3is preferred to1 2 3 4 5.
Definition: AS Path is a sequence of AS numbers a route advertisement traversed; shorter sequences are generally preferred.
Origin Code
- Three possible values: IGP, EGP, INCOMPLETE.
- Preference order: IGP < EGP < INCOMPLETE (IGP is most preferred).
MED (Multi-Exit Discriminator)
- Exchanged between ASes to convey preference for entry points.
- Lower MED is preferred.
eBGP over iBGP
- Prefer routes learned from eBGP peers over routes learned via iBGP.
IGP Metric to Next Hop
- Compare the internal IGP cost to reach the BGP next hop; prefer the lowest cost within the AS.
Oldest Path
- If still tied, prefer the path received first (the oldest). This can help stability by avoiding route flaps becoming preferred.
Router ID and Neighbor IP Address
- If all else ties, prefer the route with the lowest BGP neighbor router ID.
- If router ID values are identical (for example, both peers use the same loopback address), the final tiebreaker is the lowest neighbor IP address.
Definition: The BGP router ID is an identifier for the BGP process, usually chosen as the highest active IP address on the router or assigned manually.
Practical Example (Interpreting a BGP Table)
Consider a router with five candidate paths to prefix 1.0.0.0/24. The BGP table shows a marker > next to the chosen path, indicating the selected best path that
Already have an account? Sign in
BGP Path Selection
Klíčové pojmy: BGP evaluates attributes in a fixed order to choose one best path, Weight (Cisco-only) is evaluated first and highest wins, Local Preference is used within an AS; higher values preferred, Locally originated BGP routes are preferred over learned routes, Shorter AS path length is preferred, Origin codes preference: IGP < EGP < INCOMPLETE, MED is compared next; lower MED preferred, eBGP-sourced routes preferred over iBGP-sourced routes, Prefer lowest IGP metric to reach BGP next hop, If tied, prefer oldest path, then lowest router ID, then lowest neighbor IP