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.
Attribute categories
| Category | Examples | Meaning |
|---|---|---|
| Well-known mandatory | ORIGIN, AS_PATH, NEXT_HOP | Recognized by all speakers and required for ordinary IPv4 reachability advertisements. |
| Well-known discretionary | LOCAL_PREF, ATOMIC_AGGREGATE | Recognized by all speakers; inclusion depends on the attribute’s rules. |
| Optional transitive | COMMUNITY, AGGREGATOR | Can be carried beyond a speaker that does not recognize the attribute, under its flag rules. |
| Optional non-transitive | MED, AIGP | Not blindly propagated across unknown or unauthorized domains. |
| Local selection parameter | Weight | A 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
| Check | Default comparison in these lessons |
|---|---|
| Eligibility | Acceptable path, permitted policy and resolvable NEXT_HOP. |
| Weight | Prefer higher local weight. |
| Local preference | Prefer higher effective LOCAL_PREF. |
| Local origination | Prefer a locally originated path when earlier checks tie. |
| AIGP, when enabled | Compare eligible accumulated-cost paths before AS-path length on supporting software. |
| AS-path length | Prefer the shorter ordinary AS sequence. |
| ORIGIN | Prefer i, then e, then ?. |
| MED | Prefer lower, normally only among paths from the same neighboring AS. |
| External vs internal | Prefer eBGP when earlier comparisons tie. |
| Interior cost | Prefer the lower IGP cost to the BGP next hop. |
| Later tie-breaks | Multipath 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 iThe 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.
Protocol and command references
Best-path comparison rules · BGP path attributes · Router-symbol attribution.