PacketLab
BGP · Attributes and Path Selection

BGP Attributes and Path Selection

Compare paths for one identical prefix, stop at the first decisive difference, and keep best-path selection separate from route installation.

One prefix, several paths

R1 receives the same /24 from an internal peer R2 and external peers R3, R4 and R5. This is a conceptual comparison, not a new configuration lab. A /25 would be a different destination entry, not another candidate for the /24.

One decision point · several candidatesIllustrative network
R1AS 65010R2AS 65010R3AS 65030R4AS 65040R5AS 65050R1 compares candidates for 198.51.100.0/24
Solid lines show neighbor relationships. R1–R2 is internal; the other peers are external. Forwarding uses the most-specific installed destination prefix before the selected path for that prefix matters.

Attribute categories

CategoryExamplesMeaning
Well-known mandatoryORIGIN, AS_PATH, NEXT_HOPRecognized by all speakers and required for ordinary IPv4 reachability advertisements.
Well-known discretionaryLOCAL_PREF, ATOMIC_AGGREGATERecognized by all speakers; inclusion depends on the attribute’s rules.
Optional transitiveCOMMUNITY, AGGREGATORCan be carried beyond a speaker that does not recognize the attribute, under its flag rules.
Optional non-transitiveMED, AIGPNot blindly propagated across unknown or unauthorized domains.
Local selection parameterWeightA local implementation parameter, not an on-wire BGP path attribute.

Category does not equal comparison priority. NEXT_HOP reachability is an eligibility requirement; weight is considered early in this command family despite not being transmitted.

Comparison order

CheckDefault comparison in these lessons
EligibilityAcceptable path, permitted policy and resolvable NEXT_HOP.
WeightPrefer higher local weight.
Local preferencePrefer higher effective LOCAL_PREF.
Local originationPrefer a locally originated path when earlier checks tie.
AIGP, when enabledCompare eligible accumulated-cost paths before AS-path length on supporting software.
AS-path lengthPrefer the shorter ordinary AS sequence.
ORIGINPrefer i, then e, then ?.
MEDPrefer lower, normally only among paths from the same neighboring AS.
External vs internalPrefer eBGP when earlier comparisons tie.
Interior costPrefer the lower IGP cost to the BGP next hop.
Later tie-breaksMultipath eligibility, older external path where applicable, lower router/originator ID, route-reflector cluster checks and lower peer address, according to platform rules.

This is a practical default sequence for the example command family, not a universal list of identical behavior across all implementations. Optional cost policies and configured best-path knobs can change it. AIGP and route-reflector details have their own prerequisites.

Work through a decision

In this constructed comparison, both next hops resolve and both paths are permitted. The internal path has a higher local preference, so there is no need to compare AS-path length or session type.

R1# show ip bgp 198.51.100.0/24
     Network          Next Hop        Metric LocPrf Weight Path
*>i  198.51.100.0/24  10.255.0.2           0    200      0 65020 65060 i
*                     192.0.2.6            0             0 65030 i

The internal path wins at LOCAL_PREF 200 versus the external path’s effective 100, even though its AS path is longer. An empty LocPrf column on an external path is not proof that its effective preference is zero.

Verify the result

Inspect the detailed BGP entry to identify the decisive attribute, then check the IP route for installation. A best BGP path can lose installation to a preferred connected, static or IGP route for the same prefix. Eligible multipath configuration can install more than one forwarding next hop; it is not enabled merely because two BGP rows exist.

The following lessons isolate each earlier comparison before considering later tie-breakers. Avoid changing several attributes in one experiment.

Key Takeaways

  • Best-path comparison evaluates candidates for the same prefix and prefix length.
  • Policy eligibility and next-hop reachability precede comparisons of usable candidates.
  • The first decisive comparison wins; later attributes do not override it.
  • Weight, LOCAL_PREF, AS_PATH, ORIGIN, MED and session type have different scopes and priorities.
  • BGP best-path selection, IP-table installation and longest-prefix forwarding are separate decisions.

Path Selection Quiz

Six questions · four options each · select one answer per question. Submit all answers to see your score and explanations.

1. Which candidates compete for the same BGP destination?
2. Which path is eligible for ordinary selection?
3. LOCAL_PREF 200 has a longer AS path than LOCAL_PREF 100. With weight tied, which wins?
4. Which item is local rather than a transmitted standard BGP attribute?
5. Does the best BGP path always replace a connected route to the same prefix?
6. When can eBGP preference decide between two usable paths?
Protocol and command references

Best-path comparison rules · BGP path attributes · Router-symbol attribution.