NetworkTools
Sign In
1Static Routing2Dynamic Routing3OSPF Basics4OSPF Advanced5BGP Basics6BGP Path Selection7NAT8IPv6 Routing
← Back to Routing & IP

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:

  1. Highest weight (Cisco proprietary, local to the router)
  2. Highest LOCAL_PREF (prefer routes with higher local preference)
  3. Locally originated (routes originated by this router are preferred)
  4. Shortest AS_PATH (fewest AS numbers traversed)
  5. Lowest origin type (IGP < EGP < incomplete)
  6. Lowest MED (multi-exit discriminator)
  7. eBGP over iBGP (external paths preferred over internal)
  8. Lowest IGP metric to NEXT_HOP (closest exit point)
  9. Oldest route (for eBGP paths only)
  10. Lowest neighbor RID

Arrange the BGP best-path selection criteria in order of evaluation (1 = evaluated first, highest priority).

1.☰Prefer eBGP over iBGP
2.☰Shortest AS_PATH
3.☰Highest LOCAL_PREF
4.☰Lowest MED
5.☰Highest weight
6.☰Lowest IGP metric to NEXT_HOP
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.
Attempts: 0 | Successful: 0

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.

Two BGP paths to the same prefix. Path attributes differ in LOCAL_PREF and AS_PATH length. Apply the BGP best-path algorithm in order.

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
Dual-homed enterprise with two ISP connections. Need to prefer ISP-A for outbound traffic while keeping ISP-B as backup.

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
PreviousBGP BasicsNextNAT