Learning Objectives
- Order the BGP best-path selection algorithm steps
- Determine the best path given multiple path attributes
- Understand how LOCAL_PREF, AS_PATH, and MED influence path selection
- Apply BGP path selection in real-world multi-homed topologies
The BGP Best-Path Selection Algorithm
When a BGP router receives multiple paths to the same prefix, it must pick the single best path to install in the routing table. BGP evaluates paths sequentially, comparing attributes one at a time. The algorithm stops at the first attribute that breaks the tie.
The order of evaluation:
- Highest weight (Cisco proprietary, local to the router)
- Highest LOCAL_PREF (prefer routes with higher local preference)
- Locally originated (routes originated by this router are preferred)
- Shortest AS_PATH (fewest AS numbers traversed)
- Lowest origin type (IGP < EGP < incomplete)
- Lowest MED (multi-exit discriminator)
- eBGP over iBGP (external paths preferred over internal)
- Lowest IGP metric to NEXT_HOP (closest exit point)
- Oldest route (for eBGP paths only)
- Lowest neighbor RID
Arrange the BGP best-path selection criteria in order of evaluation (1 = evaluated first, highest priority).
Hints
- Weight is checked first (but is Cisco-proprietary).
- LOCAL_PREF comes second — it's the primary policy tool.
- MED is evaluated after origin type.
- eBGP is preferred over iBGP before checking IGP metric.
Understanding Each Attribute
Weight — A Cisco-proprietary, locally significant value (0-65535). Higher weight wins. Weight only affects the local router and is not advertised to peers. It is checked first, making it the most powerful attribute for local policy.
LOCAL_PREF — An integer (0-4294967295) exchanged within the AS via iBGP. Higher is better. Standard default is 100. This is the primary tool for influencing outbound traffic from the AS.
AS_PATH — The list of AS numbers a route traversed. Shorter is preferred. BGP operators can use as-path prepend to artificially lengthen the AS_PATH and make a path less preferred.
MED (Multi-Exit Discriminator) — An integer exchanged between ASes to influence inbound traffic. Lower MED is better. Unlike LOCAL_PREF, MED is non-transitive — it stays within the neighboring AS and is not propagated further.
R1 receives two paths to 10.0.0.0/16. Path A has LOCAL_PREF 150 and AS_PATH 65001 64500. Path B has LOCAL_PREF 100 and AS_PATH 65001. Which path wins and why?
Multi-Homing Scenarios
An organization connected to two ISPs (multi-homed) can use BGP attributes to engineer traffic:
Controlling outbound traffic (which ISP your traffic uses to reach the internet):
- Set higher LOCAL_PREF on routes received from the preferred ISP
- Or set lower LOCAL_PREF on routes from the backup ISP
Controlling inbound traffic (which ISP carries traffic coming into your network):
- Advertise shorter AS_PATH to preferred ISP
- Or advertise a longer AS_PATH (prepend) to make the backup ISP less attractive
An enterprise has eBGP peers with ISP-A and ISP-B. They want all outbound traffic to prefer ISP-A unless ISP-A is down. What attribute should they adjust?
Which BGP attribute is used to influence inbound traffic from a neighboring AS?
If R1 receives two identical paths to 192.168.0.0/24 — one via eBGP and one via iBGP — which wins?
Key Takeaways
- BGP evaluates 10 path attributes in a strict sequential order
- Weight and LOCAL_PREF control outbound traffic; MED controls inbound traffic
- AS_PATH prepend makes a path artificially longer and thus less preferred
- Multi-homed networks use BGP attributes for traffic engineering
- Understanding the order of evaluation is critical for correct BGP policy design