Cisco CCNP Enterprise (ENCOR 350-401) · lesson 5 of 12 · 35 min
BGP Path Selection: The 13-Step Algorithm
When BGP has multiple paths to the same prefix, it runs a deterministic selection algorithm to choose the single best path. This algorithm is one of the most tested topics on the CCNP ENCOR exam. You must know the order, what each step means, and which attributes you can manipulate to influence the outcome. Memory Aid: We Love Oranges As Oranges Mean Pure Refreshment W — Weight (highest wins) · L — LOCAL_PREF (highest wins) · O — Originated locally (network/redistribute/aggregate) · A — AS_PATH (shortest wins) · O — ORIGIN (IGP > EGP > Incomplete) · M — MED (lowest wins) · P — Prefer eBGP over iBGP · R — RID (lowest router ID wins) · … and neighbor IP as final tiebreaker
BGP Attributes Deep Dive
BGP attributes are categorized as well-known mandatory, well-known discretionary, optional transitive, and optional non-transitive. Understanding this matters for the exam.
Influencing Inbound Traffic: LOCAL_PREF and AS_PATH Prepend
LOCAL_PREF is the primary tool for influencing which exit point your AS uses for outbound traffic. Set it high on the preferred path, low on the backup path. It’s shared with all iBGP peers so the entire AS agrees on the preferred exit. AS_PATH prepend is the primary tool for influencing which path remote ASes use to reach you (inbound traffic). By prepending your own AS number multiple times, you make a path appear longer — other ASes will prefer the shorter path. Outbound vs Inbound Traffic Control Outbound (you choose the exit): LOCAL_PREF (high = preferred) or Weight (high = preferred, local only). Inbound (you influence remote AS choices): AS_PATH prepend (longer = less preferred) or MED (lower = preferred, limited scope).
MED: Multi-Exit Discriminator
MED tells a neighboring AS which entry point you prefer when they have multiple connections to you. It’s only compared between paths from the same AS (by default). Lower MED is preferred.
BGP Communities
BGP communities are 32-bit tags attached to routes that allow policy to be applied at scale. Instead of writing complex route-maps for every prefix, you tag routes with a community and apply policy based on the tag.
Communities are not sent to eBGP peers by default. Use
neighbor x.x.x.x send-community
to enable community propagation to a specific peer.
Worked Scenario: Dual-Homed BGP Policy
Scenario Your AS (65001) has two eBGP connections: ISP-A (preferred) and ISP-B (backup). You want all outbound traffic to use ISP-A. You want inbound traffic from the internet to prefer ISP-A’s path to you. Outbound preference (LOCAL_PREF): Apply a route-map on the ISP-A eBGP session setting LOCAL_PREF 200 for all received routes. Apply a route-map on ISP-B setting LOCAL_PREF 100. All iBGP peers will prefer ISP-A for outbound traffic. Inbound preference (AS_PATH prepend): Apply a route-map on the ISP-B eBGP session that prepends your AS number 3 times when advertising your prefixes. ISP-B’s path to you appears 3 hops longer — internet routers prefer ISP-A’s shorter path. Result: Outbound traffic exits via ISP-A (LOCAL_PREF 200 wins). Inbound traffic arrives via ISP-A (shorter AS_PATH wins). ISP-B is a true backup for both directions.
Flashcard Drill
Weight Cisco-only, local to router, not advertised. Highest wins. Step 1 in BGP path selection. LOCAL_PREF Shared within AS via iBGP. Highest wins. Controls outbound traffic exit point. Default 100. AS_PATH prepend Makes a path appear longer by adding your own AS multiple times. Used to influence inbound traffic. MED Advertised to neighboring AS to suggest preferred entry point. Lowest wins. Only compared from same AS by default. ORIGIN attribute i = IGP (network cmd), e = EGP (obsolete), ? = incomplete (redistribute). IGP preferred. no-export community Route is not advertised to eBGP peers — stays within the AS. send-community Required to propagate BGP communities to eBGP peers — not sent by default. BGP path selection step 4 Shortest AS_PATH wins — count the number of AS numbers in the path. LOCAL_PREF default 100 — routes with LOCAL_PREF above 100 are preferred; below 100 are less preferred.
Knowledge Check — 12 Questions
BGP Path Selection & Attributes
Which BGP attribute is checked FIRST in the path selection algorithm?
- LOCAL_PREF
- AS_PATH
- Weight
- MED
Answer: Weight
Weight is step 1. It is Cisco-proprietary, local to the router, and not advertised to any peer. Highest weight wins.
Which attribute is the primary tool for controlling OUTBOUND traffic from your AS?
- MED
- AS_PATH prepend
- LOCAL_PREF
- Weight
Answer: LOCAL_PREF
LOCAL_PREF is shared with all iBGP peers — the entire AS agrees on the preferred exit. Highest LOCAL_PREF wins.
Which attribute is the primary tool for influencing INBOUND traffic from remote ASes?
- LOCAL_PREF
- AS_PATH prepend
- Weight
- COMMUNITY
Answer: AS_PATH prepend
AS_PATH prepend makes your path appear longer to remote ASes, causing them to prefer a shorter path to reach you.
What does the no-export BGP community do?
- Prevents the route from being installed in the routing table
- Prevents the route from being advertised to eBGP peers
- Removes the route from the BGP table
- Sets LOCAL_PREF to 0
Answer: Prevents the route from being advertised to eBGP peers
no-export (0xFFFFFF01) tells BGP not to advertise the route to any eBGP peers — it stays within the AS.
MED is compared between paths from different ASes by default.
- True
- False
Answer: False
By default, MED is only compared between paths from the SAME neighboring AS. Use bgp always-compare-med to compare across different ASes.
The default LOCALPREF value is ____.
Answer: 100
LOCAL_PREF defaults to 100. Routes with higher LOCAL_PREF are preferred for outbound traffic.
Which ORIGIN code indicates a route was redistributed into BGP (not via the network command)?
- i (IGP)
- e (EGP)
- ? (incomplete)
- r (redistributed)
Answer: ? (incomplete)
The ? (incomplete) origin code means the route was redistributed into BGP. The i (IGP) code means it was added via the network command.
What command is required to send BGP communities to an eBGP peer?
- neighbor x.x.x.x community
- neighbor x.x.x.x send-community
- bgp community propagate
- ip community-list send
Answer: neighbor x.x.x.x send-community
BGP communities are not sent to eBGP peers by default. send-community must be explicitly configured per neighbor.
In BGP path selection, what happens when Weight and LOCAL_PREF are equal?
- The route is dropped
- BGP checks if the route was locally originated
- BGP immediately uses the lowest router ID
- BGP uses MED
Answer: BGP checks if the route was locally originated
Step 3 in BGP path selection: prefer routes originated by this router (via network, redistribute, or aggregate commands).
Which BGP attribute category means the attribute must be present in every BGP UPDATE?
- Optional transitive
- Optional non-transitive
- Well-known mandatory
- Well-known discretionary
Answer: Well-known mandatory
Well-known mandatory attributes (AS_PATH, NEXT_HOP, ORIGIN) must be present in every BGP UPDATE message.
What is the scope of the Weight attribute?
- Shared with all iBGP peers in the AS
- Advertised to eBGP peers
- Local to the router only — not advertised to any peer
- Shared between directly connected routers
Answer: Local to the router only — not advertised to any peer
Weight is Cisco-proprietary and local to the router. It is never advertised to any BGP peer.
When comparing two BGP paths with equal attributes through step 6 (MED), what is checked next?
- Lowest router ID
- Prefer eBGP over iBGP
- Shortest AS_PATH
- Highest LOCAL_PREF
Answer: Prefer eBGP over iBGP
Step 7 in BGP path selection: prefer eBGP-learned routes over iBGP-learned routes.
Previous lesson: BGP concepts: eBGP, iBGP, AS numbers, neighbor relationships, route reflectors
Back to Cisco CCNP Enterprise (ENCOR 350-401)
Next lesson: BGP route filtering: prefix-lists, route-maps, communities, conditional advertisement