Study guide

6.2 BGP Path Attributes and the Step-by-Step Best Path Selection Algorithm

Cisco ENCOR 350-401 CCNP Enterprise Core

Track your progress as you read

Finished sections get a check mark.

1 Introduction & Exam Overview

0.1 Cisco 350-401 ENCOR Exam Logistics, Blueprint Structure, and Certification Paths 0.2 Preparation Strategy, Lab Environment Setup, and Practical Test Pacing

2 Enterprise Campus Architecture and High Availability

1.1 Enterprise Network Design: Two-Tier, Three-Tier, Fabric, and Cloud Architectures 1.2 High Availability Architecture: Device Redundancy, FHRPs, and Stateful Switchover (SSO) 1.3 Quality of Service (QoS) Architecture, Classification, Queuing, and Configuration Interpretation

3 Cisco Software-Defined Architecture: SD-WAN and SD-Access

2.1 Cisco Catalyst SD-WAN: Control, Management, and Data Planes 2.2 Cisco SD-Access Architecture: Control Plane, Data Plane, and Fabric Node Roles 2.3 SD-Access Campus Interoperability: Integrating Traditional Networks with Fabric

4 Device and Network Virtualization Technologies

3.1 Device Virtualization: Type 1/2 Hypervisors, Virtual Machines, and Virtual Switching 3.2 Data Path Virtualization: VRF-Lite, GRE Tunneling, and IPsec VPN Fundamentals 3.3 Network Virtualization Overlays: LISP and VXLAN Encapsulation Mechanics

5 Layer 2 Infrastructure: Trunking, EtherChannel, and Spanning Tree

4.1 802.1Q Trunking, Native VLAN, and Dynamic Trunking Protocol Troubleshooting 4.2 EtherChannel Bundling: Static, LACP, and PAgP Implementation and Verification 4.3 Spanning Tree Architecture: RSTP, MST, and STP Protection Mechanisms

6 Layer 3 Routing: OSPF Multi-Area and Protocol Comparison

5.1 Enterprise Routing Principles: Distance Vector vs. Link-State, EIGRP, and OSPF 5.2 OSPFv2 and OSPFv3 Multi-Area Architecture: LSAs, Area Types, and Summarization 5.3 Policy-Based Routing (PBR) Architecture, Configuration, and Route-Maps

7 Exterior Routing: BGP Peering and Path Selection

6.1 External BGP (eBGP) Peering, States, Neighbor Adjacencies, and Timers 6.2 BGP Path Attributes and the Step-by-Step Best Path Selection Algorithm

8 IP Services and First-Hop Redundancy

7.1 Time Synchronization: Network Time Protocol (NTP) and Precision Time Protocol (PTP) 7.2 Network Address Translation: Static NAT, Dynamic NAT, and PAT/Overload 7.3 First Hop Redundancy Protocols: HSRP and VRRP Implementation and Failover

9 IP Multicast Architecture and Protocols

8.1 Multicast Addressing, IGMPv2/v3 Host Membership, and the RPF Check 8.2 Protocol Independent Multicast Sparse Mode (PIM-SM) and Rendezvous Point Discovery 8.3 Anycast RP with MSDP, Source-Specific Multicast (SSM), and Bidirectional PIM

10 Network Diagnostics, Monitoring, and Telemetry

9.1 Network Diagnostic Tools: Conditional Debugging, Traceroute, SNMPv3, and Syslog Logging 9.2 Flexible NetFlow (FNF) Architecture: Flow Records, Exporters, and Monitors 9.3 Switched Port Analyzer: Local SPAN, Remote SPAN (RSPAN), and Encapsulated RSPAN (ERSPAN)

11 Performance Monitoring and Model-Driven Assurance

10.1 IP Service Level Agreements (IP SLA) Probes, Responder, and Route Tracking 10.2 Cisco Catalyst Center: Assurance Dashboards, AI Analytics, and Machine Reasoning Workflows 10.3 Model-Driven Telemetry and Programmable Interfaces: NETCONF and RESTCONF Verification

12 Device Access Control and AAA Architecture

11.1 Device Line Protection: Console, Aux, VTY, Local Authentication, and Privilege Levels 11.2 AAA Architecture: Comparing RADIUS vs. TACACS+ and Method List Configuration

13 Infrastructure Security: ACLs, CoPP, and API Security

12.1 IPv4 and IPv6 Access Control Lists (ACLs): Standard, Extended, and Named Rules 12.2 Control Plane Policing (CoPP): Protecting the Route Processor with MQC 12.3 REST API Security: Token Authentication, TLS Transport, and Rate Limiting

14 Enterprise Network Security Design: ISE, TrustSec, and MACsec

13.1 Endpoint Security Architecture: 802.1X, Cisco ISE Posture, and Profiling 13.2 Next-Generation Firewalls (FTD) and Enterprise Threat Defense Design 13.3 Cisco TrustSec (Security Group Tags) and MACsec (802.1AE) Layer 2 Encryption

15 Network Automation Fundamentals: Python, JSON, and YANG

14.1 Python Fundamentals for Network Engineers: Data Types, Control Flow, and Libraries 14.2 JSON Data Encoding: Syntax, Formatting Rules, and Python Serialization 14.3 YANG Data Modeling: Modules, Tree Structures, and Data Representation

16 Controller REST APIs and RESTCONF Implementation

15.1 Cisco Catalyst Center Intent APIs and Authentication Workflows 15.2 Cisco Catalyst SD-WAN Manager (vManage) REST APIs and Device Interaction 15.3 RESTCONF Protocol Operations: HTTP Verbs, Datastores, and Response Codes

17 Event-Driven Automation and Infrastructure Orchestration

16.1 Cisco Embedded Event Manager (EEM) Applet Architecture and Event Detectors 16.2 Configuration Management: Comparing Ansible, Puppet, Chef, and SaltStack 16.3 Infrastructure as Code (IaC) Principles with Terraform in Enterprise Networks

6.2 BGP Path Attributes and the Step-by-Step Best Path Selection Algorithm

Key Takeaways Explain This Topic AI

BGP path attributes are categorized into four distinct classes: Well-known Mandatory, Well-known Discretionary, Optional Transitive, and Optional Non-transitive.

Cisco's BGP best path selection algorithm evaluates attributes in a deterministic sequence, beginning with Cisco-proprietary Weight (local to router), followed by Local Preference (AS-wide), and locally originated routes.

Path length and metric tie-breakers prioritize shortest AS_PATH, lowest Origin code (IGP < EGP < Incomplete), lowest MED, eBGP over iBGP, and lowest IGP metric to the BGP next-hop.

Inbound traffic engineering influences external AS path selection via AS_PATH prepending and Multi-Exit Discriminator (MED), while outbound traffic engineering is managed locally via Weight and Local Preference.

Final BGP deterministic tie-breakers resolve equal candidate paths through oldest eBGP path, lowest BGP Router ID (RID), and lowest neighbor peering IP address.

Last updated: October 2026

BGP Path Attributes and the Step-by-Step Best Path Selection Algorithm

Border Gateway Protocol (BGP) is fundamentally a policy-driven routing engine rather than a pure shortest-path protocol. Unlike Interior Gateway Protocols that compute link costs from physical metrics such as bandwidth or interface delay, BGP equips network administrators with granular administrative control over transit paths across autonomous boundaries. When a BGP speaker learns multiple paths to the exact same prefix with the same subnet mask, it subjects all candidate paths to a rigorous, sequential decision ladder known as the BGP Best Path Selection Algorithm .

BGP Path Attribute Classification Matrix

Every BGP route is bundled with path attributes that describe its origin, forwarding characteristics, and administrative preference. RFC standards classify BGP path attributes into four distinct operational categories: +-----------------------------+

  • | BGP Path Attributes |
  • +-----------------------------+
  • / \
  • / \
  • +---------------+ +--------------+
  • | Well-Known | | Optional |
  • +---------------+ +--------------+
  • / \ / \
  • / \ / \
  • +-----------+ +---------------+ +----------+ +--------------+
  • | Mandatory | | Discretionary | |Transitive| |Non-Transitive|
  • +-----------+ +---------------+ +----------+ +--------------+
  • | AS_PATH | | LOCAL_PREF | |COMMUNITY | | MED |
  • | NEXT_HOP | | ATOMIC_AGGR | |AGGREGATOR| | ORIGINATOR_ID|
  • | ORIGIN | +---------------+ +----------+ | CLUSTER_LIST |
  • +-----------+ +--------------+

Category Definition and Behavioral Rules Key Path Attributes

Well-Known Mandatory Must be recognized by all compliant BGP implementations and must be included in every BGP Update advertisement. • AS_PATH : Ordered sequence of ASNs traversed; • NEXT_HOP : Next-hop IP address to forward traffic toward; • ORIGIN : Historical origin of route (IGP i , EGP e , Incomplete ? ).

Well-Known Discretionary Must be recognized by all compliant BGP implementations, but optional to include in an Update advertisement. • LOCAL_PREF : Egress path preference across an AS (default 100); • ATOMIC_AGGREGATE : Informs downstream peers that route summarization suppressed more specific prefix details.

Optional Transitive Implementations may or may not support it. If unrecognized, the router must accept and preserve the attribute, propagating it to downstream peers. • COMMUNITIES : 32-bit tagging values for route policy; • AGGREGATOR : Identifies BGP Router ID and ASN of aggregating router.

Optional Non-Transitive Implementations may or may not support it. If unrecognized, the router silently drops the attribute and does not propagate it to other peers. • MULTI_EXIT_DISC (MED) : Metric used to suggest ingress preference to a neighboring AS; • ORIGINATOR_ID : Router ID of route creator (Route Reflector loop prevention); • CLUSTER_LIST : List of cluster IDs traversed within RR topologies.

Cisco Weight Attribute: The Cisco-proprietary Weight attribute is not exchanged between BGP neighbors and is never carried in BGP Update messages. It is purely local to the router on which it is configured.

The Step-by-Step BGP Best Path Selection Algorithm

When a Cisco router receives multiple valid paths to an identical IP prefix and mask, it executes the following 12-step decision ladder in strict sequential order. Evaluation stops immediately as soon as a single tie-breaker selects a winning path: [Evaluate Candidate Paths]

  • |
  • v
  • 1. Highest Weight (Cisco Local)
  • |
  • v
  • 2. Highest Local Preference (AS-Wide)
  • |
  • v
  • 3. Prefer Locally Originated Routes
  • |
  • v
  • 4. Shortest AS_PATH Length
  • |
  • v
  • 5. Lowest Origin Code (IGP < EGP < ?)
  • |
  • v
  • 6. Lowest MED (Metric from Neighbor AS)
  • |
  • v
  • 7. Prefer eBGP over iBGP Paths
  • |
  • v
  • 8. Lowest IGP Metric to the BGP Next_Hop
  • |
  • v
  • 9. Multipath (Install ECMP if enabled)
  • |
  • v
  • 10. Oldest eBGP Path (Route Stability)
  • |
  • v
  • 11. Lowest BGP Router ID (RID)
  • |
  • v
  • 12. Lowest Neighbor Peering IP Address
  • Step 1: Highest Weight (Cisco Proprietary)

Scope: Purely local to the router. It is never advertised to any BGP peer (eBGP or iBGP).

Range: 0 to 65,535 . Defaults to 32,768 for locally originated routes (via network or redistribute ) and 0 for all routes learned from neighbors.

Tie-Breaker: The path with the highest Weight wins.

Step 2: Highest Local Preference ( LOCAL_PREF )

Scope: Propagated throughout the entire local Autonomous System across all iBGP peers. It is never transmitted across eBGP peering boundaries.

Range: 0 to 4,294,967,295 . Default value is 100 .

Tie-Breaker: The path with the highest Local Preference wins. This is the primary mechanism for controlling outbound Internet traffic for an enterprise.

Step 3: Locally Originated Routes

Prefers paths that were originated locally on this router over paths learned from other routers.

Cisco's documented order: local paths sourced by network or redistribute are preferred over local aggregates created with aggregate-address , and any locally originated path beats a path learned from a neighbor.

Step 4: Shortest AS_PATH Length

Counts the number of Autonomous System numbers in the AS_PATH attribute list.

Tie-Breaker: The path with the fewest AS numbers wins.

Rules: An AS_SET counts as 1 AS number regardless of how many ASNs are in the set. AS confederation sequences ( AS_CONFED_SEQUENCE ) do not count toward AS_PATH length.

Step 5: Lowest Origin Code

Evaluates how the prefix was initially introduced into BGP:

IGP ( i ): Originated via BGP network command (most preferred).

EGP ( e ): Originated via legacy Exterior Gateway Protocol (historic; intermediate preference).

Incomplete ( ? ): Originated via route redistribution into BGP (least preferred).

Hierarchy: IGP (i) < EGP (e) < Incomplete (?) .

Step 6: Lowest Multi-Exit Discriminator ( MED )

Scope: Transmitted to neighboring external ASes to influence their ingress choice. By default, MED is only compared between routes advertised by the same neighboring Autonomous System .

Tie-Breaker: The path with the lowest MED (metric) wins. A missing MED attribute is treated as metric 0 by default in Cisco IOS.

Configuration Override: The bgp always-compare-med router configuration command forces the router to compare MED across paths originating from different autonomous systems.

Step 7: Prefer eBGP over iBGP Paths

Paths learned from external eBGP peers are preferred over paths learned from internal iBGP peers.

Confederation eBGP paths ( eBGP confederation ) are treated as having an intermediate preference between pure eBGP and iBGP.

Step 8: Lowest IGP Metric to the BGP Next_Hop

Evaluates the internal IGP routing table (OSPF, EIGRP, IS-IS) to find the metric cost to reach the BGP NEXT_HOP IP address.

Tie-Breaker: The path with the lowest IGP metric to the exit next-hop wins. This implements "hot potato routing"—shedding transit packets out of the local autonomous system as quickly as possible.

Step 9: Multipath (Equal-Cost Multi-Path)

If the router is configured with maximum-paths <n> under router bgp , and multiple candidate paths are identical from Step 1 through Step 8, BGP installs multiple paths into the routing table for parallel ECMP forwarding.

Step 10: Oldest eBGP Path (Stability)

For eBGP paths, the router prefers the path that has been known for the longest duration (the oldest route). This prevents route flapping when a temporary link toggle occurs.

Note: This step is bypassed if bgp bestpath compare-routerid is enabled.

Step 11: Lowest BGP Router ID (RID)

Compares the 32-bit BGP Router IDs of the advertising neighbors. The path with the lowest Router ID wins.

Route Reflector Exception: If the route was received through a BGP Route Reflector, the ORIGINATOR_ID attribute is compared instead of the advertising neighbor's Router ID.

Step 12: Lowest Neighbor Peering IP Address

The final deterministic tie-breaker: prefers the path learned from the neighbor with the lowest IP address .

Route Reflector note: when paths arrive through route reflectors, Cisco compares CLUSTER_LIST length (shorter wins) just before this step.

Master BGP Best Path Tie-Breaker Table

  • Step Evaluation Criterion Scope / Propagation Default Value Preference Direction
  • 1 Weight Router-local only (never advertised) 0 (learned), 32768 (local) Highest
  • 2 Local Preference AS-wide (flooded across iBGP) 100 Highest
  • 3 Locally Originated Local router N/A Local > Remote
  • 4 AS_PATH Length Global (propagated everywhere) Dynamic list Shortest
  • 5 Origin Code Global (propagated everywhere) i , e , or ? Lowest ( i < e < ? )
  • 6 MED (Metric) Inter-AS (adjacent neighbor AS) 0 Lowest
  • 7 Peer Type Inter-AS vs. Intra-AS eBGP vs. iBGP eBGP > iBGP
  • 8 IGP Cost to Next_Hop Local AS (interior routing table) IGP metric (OSPF/EIGRP) Lowest
  • 9 Multipath Local router forwarding plane Disabled (default 1) ECMP installation
  • 10 Route Age Local router (eBGP paths only) Uptime timestamp Oldest (Most Stable)
  • 11 BGP Router ID Neighbor BGP process ID 32-bit dotted-decimal Lowest
  • 12 Neighbor Peering IP Peering TCP endpoint IPv4/IPv6 address Lowest
  • Traffic Engineering: Inbound vs. Outbound Control

Enterprise networks dual-homed to multiple Service Providers must manipulate BGP attributes to steer traffic deterministically:

1. Outbound Traffic Engineering (Influencing Local Egress)

To control how traffic inside your enterprise exits toward external destinations, configure Local Preference or Weight on routes received from upstream ISPs:

Local Preference (Recommended): Applied to incoming eBGP route updates. Because Local Preference is carried across all iBGP routers, setting LOCAL_PREF 200 on ISP-1 and LOCAL_PREF 100 on ISP-2 ensures that all internal routers egress through ISP-1.

Weight: Applied to incoming routes on a single border router. Effective only if a single router terminates both ISP connections.

2. Inbound Traffic Engineering (Influencing External Ingress)

To control how external networks send traffic into your enterprise, configure AS_PATH Prepending or MED on routes advertised out to ISPs:

AS_PATH Prepending: Artificially lengthens the AS_PATH advertised to a secondary ISP by repeating your own AS number multiple times (e.g., set as-path prepend 65100 65100 65100 ). Upstream BGP speakers observe a longer path and prefer the primary ISP.

Multi-Exit Discriminator (MED): Advertising a lower MED on the primary link and higher MED on the backup link signals the adjacent ISP to prefer the primary link. Note that MED only influences the immediate neighbor AS and may be overridden by the ISP's local preference policy.

Cisco IOS Route Manipulation Implementation

The following configuration demonstrates outbound egress steering via Local Preference and inbound ingress steering via AS_PATH prepending on Router R1 (AS 65100): ! Define prefix-list matching local public enterprise subnet

ip prefix-list PL_LOCAL_PREFIX permit 192.0.2.0/24

!

  • ! Outbound policy: Prefer ISP-1 for Internet egress by setting Local_Pref 200
  • route-map RM_FROM_ISP1_IN permit 10
  • set local-preference 200

!

  • route-map RM_FROM_ISP2_IN permit 10
  • set local-preference 100

!

  • ! Inbound policy: Deprioritize ISP-2 for incoming traffic via AS-Path prepending
  • route-map RM_TO_ISP1_OUT permit 10
  • match ip address prefix-list PL_LOCAL_PREFIX

!

  • route-map RM_TO_ISP2_OUT permit 10
  • match ip address prefix-list PL_LOCAL_PREFIX
  • set as-path prepend 65100 65100 65100

!

  • router bgp 65100
  • neighbor 198.51.100.2 remote-as 65200
  • neighbor 198.51.100.2 description Primary ISP-1
  • neighbor 198.51.100.2 route-map RM_FROM_ISP1_IN in
  • neighbor 198.51.100.2 route-map RM_TO_ISP1_OUT out

!

  • neighbor 203.0.113.2 remote-as 65300
  • neighbor 203.0.113.2 description Backup ISP-2
  • neighbor 203.0.113.2 route-map RM_FROM_ISP2_IN in
  • neighbor 203.0.113.2 route-map RM_TO_ISP2_OUT out
  • BGP Table Analysis and Verification

Interpreting the show ip bgp output is essential for identifying which path won the best-path algorithm: R1# show ip bgp 203.0.113.0/24

  • BGP routing table entry for 203.0.113.0/24, version 14
  • Paths: (2 available, best #1, table default)

Advertised to update-groups:

  • 1
  • Refresh Epoch 1
  • 65200
  • 198.51.100.2 from 198.51.100.2 (198.51.100.2)
  • Origin IGP, metric 0, localpref 200, weight 0, valid, external, best
  • rx path info: flag 0x41, orig-as 65200, localpref 200, metric 0
  • Refresh Epoch 1
  • 65300
  • 203.0.113.2 from 203.0.113.2 (203.0.113.2)
  • Origin IGP, metric 0, localpref 100, weight 0, valid, external
  • rx path info: flag 0x01, orig-as 65300, localpref 100, metric 0

In standard table summaries ( show ip bgp ), look for the status indicator codes:

* : The route is valid (the next-hop is resolvable in the routing table).

> : The route is chosen as the best path and is installed into the IP Routing Information Base (RIB).

i : The route was learned via an internal iBGP peer.