BGP Path Selection: Attributes, Best Path Algorithm + Free Quiz
In This Guide
What is BGP?
Border Gateway Protocol (BGP) is the routing protocol that powers the internet. It's a path-vector protocol used to exchange routing information between autonomous systems (AS) - independently managed networks operated by ISPs, enterprises, and cloud providers.
Unlike OSPF or EIGRP (which find the shortest path within a single network), BGP is designed to make policy-based routing decisions across organizational boundaries. Every ISP, every cloud provider, and every large enterprise uses BGP.
eBGP vs iBGP
| Feature | eBGP (External) | iBGP (Internal) |
|---|---|---|
| Peers | Different autonomous systems | Same autonomous system |
| Default TTL | 1 (directly connected) | 255 (can be multi-hop) |
| Next-Hop | Changed to self by default | Not changed by default |
| AD | 20 | 200 |
| Peering | Usually directly connected | Full mesh or route reflectors |
| AS Path | Prepends local AS number | Does not modify AS Path |
BGP uses TCP port 179 for neighbor communication. Unlike OSPF (which discovers neighbors via multicast), BGP neighbors must be manually configured.
BGP Path Selection Algorithm
When BGP receives multiple paths to the same destination prefix, it uses a well-defined algorithm to select the best path. On Cisco routers, the attributes are evaluated in this order:
| Step | Attribute | Preference | Scope |
|---|---|---|---|
| 1 | Weight | Highest wins | Local to router (Cisco-proprietary) |
| 2 | Local Preference | Highest wins | Shared within AS (iBGP) |
| 3 | Locally Originated | Local routes preferred | Network/redistribute/aggregate |
| 4 | AS Path Length | Shortest wins | Global (carried in updates) |
| 5 | Origin Type | IGP < EGP < Incomplete | Global |
| 6 | MED | Lowest wins | Between neighboring ASes |
| 7 | eBGP over iBGP | eBGP preferred | Local decision |
| 8 | IGP Metric to Next Hop | Lowest wins | Local (hot-potato routing) |
| 9 | Oldest eBGP Route | Oldest wins | Stability preference |
| 10 | Lowest Router ID | Lowest wins | Tiebreaker |
Key BGP Attributes Explained
Weight (Cisco-Proprietary)
Weight is evaluated first and is local to the router - it is not advertised to any neighbors. Default weight is 0 for learned routes and 32768 for locally originated routes. Higher weight is preferred.
route-map SET-WEIGHT permit 10
set weight 200
!
router bgp 65001
neighbor 10.0.0.2 route-map SET-WEIGHT in
Local Preference
Local Preference is shared across all routers within the AS via iBGP. Default value is 100. Higher is preferred. It's the primary tool for choosing which exit point your AS uses to reach external destinations.
route-map PREFER-ISP1 permit 10
set local-preference 200
!
router bgp 65001
neighbor 203.0.113.1 route-map PREFER-ISP1 in
AS Path
The AS Path lists every autonomous system a route has passed through. BGP prefers the shortest AS Path (fewest AS hops). Engineers use AS Path prepending to artificially lengthen a path and make it less preferred - this is the primary tool for influencing inbound traffic from other ASes.
route-map PREPEND-OUT permit 10
set as-path prepend 65001 65001 65001
!
router bgp 65001
neighbor 198.51.100.1 route-map PREPEND-OUT out
MED (Multi-Exit Discriminator)
MED is a suggestion to an external neighbor about which entry point into your AS to prefer. Lower MED is better. Unlike Local Preference, MED is sent to eBGP peers. By default, MED is only compared between paths from the same neighboring AS.
route-map SET-MED permit 10
set metric 50
!
router bgp 65001
neighbor 203.0.113.1 route-map SET-MED out
BGP Configuration Basics
Here's how to configure basic BGP peering on a Cisco IOS router:
! Enable BGP with your AS number
router bgp 65001
! Set a stable Router ID
bgp router-id 1.1.1.1
! Disable auto-summary (default in modern IOS)
no auto-summary
! Configure eBGP neighbor in AS 65002
neighbor 10.0.0.2 remote-as 65002
! Advertise your networks
network 192.168.1.0 mask 255.255.255.0
network 192.168.2.0 mask 255.255.255.0
router bgp 65001
! iBGP neighbor (same AS)
neighbor 10.0.1.2 remote-as 65001
! Use loopback for iBGP peering (stability)
neighbor 10.0.1.2 update-source Loopback0
! Set next-hop-self for iBGP peers
neighbor 10.0.1.2 next-hop-self
Key verification commands:
show ip bgp summary ! View BGP neighbors and state
show ip bgp ! View BGP table with attributes
show ip bgp neighbors ! Detailed neighbor information
show ip bgp 192.168.1.0/24 ! View specific prefix details
show ip bgp summary, the State/PfxRcd column shows the number of prefixes received. If it shows a state name like "Active" or "Idle", the peering is not established - check IP reachability, AS numbers, and TCP port 179 connectivity.BGP Route Filtering
BGP provides multiple mechanisms to control which routes are advertised or accepted:
Prefix Lists
Filter routes based on network prefix and mask length. More efficient than access lists for BGP filtering.
! Only accept /24 or shorter prefixes from this neighbor
ip prefix-list FILTER-IN seq 10 permit 0.0.0.0/0 le 24
!
router bgp 65001
neighbor 10.0.0.2 prefix-list FILTER-IN in
Route Maps
The most flexible filtering tool. Route maps can match on multiple criteria and modify BGP attributes simultaneously.
! Match a specific prefix and set Local Preference
ip prefix-list MATCH-PREFIX seq 10 permit 10.0.0.0/8
!
route-map POLICY-IN permit 10
match ip address prefix-list MATCH-PREFIX
set local-preference 200
route-map POLICY-IN permit 20
! Allow everything else with default attributes
!
router bgp 65001
neighbor 10.0.0.2 route-map POLICY-IN in
BGP Communities
Communities are tags attached to routes that allow flexible policy signaling between ASes. Common well-known communities include no-export (don't advertise to eBGP peers) and no-advertise (don't advertise to any peer).
BGP on the CCNA vs CCNP
| Topic | CCNA 200-301 | CCNP ENARSI 300-410 |
|---|---|---|
| BGP Purpose & Use Cases | Yes - conceptual | Yes - in depth |
| eBGP vs iBGP | Basic understanding | Full configuration |
| AS Numbers | What they are | Public vs private, 4-byte ASN |
| Path Selection | Not tested | Full algorithm, all attributes |
| Configuration | Not tested | Full config, troubleshooting |
| Route Filtering | Not tested | Prefix lists, route maps, communities |
| Route Reflectors | Not tested | Design and configuration |
Get the Complete CCNA Study Guide
When you purchase a CCNA practice exam, you get full access to our comprehensive study guides covering every exam topic in depth - not just the free samples here.
Want to go deeper?
BGP Path Selection Practice Questions
Test your understanding with these 5 expert-created questions. Each includes a detailed explanation to reinforce your learning.
Ready for More?
You've just covered BGP Path Selection. Here's how to keep preparing:
Frequently Asked Questions
Is BGP on the CCNA exam?
BGP is only lightly covered on the CCNA 200-301. You need to understand basic BGP concepts like what BGP does, eBGP vs iBGP, and that it's a path-vector protocol used between autonomous systems. Deep BGP configuration and path selection are tested on the CCNP ENARSI (300-410) exam.
What is the BGP best path selection order?
Cisco BGP evaluates attributes in this order: 1) Highest Weight (Cisco-proprietary), 2) Highest Local Preference, 3) Locally originated routes, 4) Shortest AS Path, 5) Lowest Origin type (IGP < EGP < Incomplete), 6) Lowest MED, 7) eBGP over iBGP, 8) Lowest IGP metric to next hop, 9) Oldest eBGP route, 10) Lowest Router ID. The mnemonic "We Love Oranges AS Oranges Mean Pure Refreshment" can help remember the order.
What is the difference between eBGP and iBGP?
eBGP (External BGP) runs between routers in different autonomous systems and is used for inter-domain routing on the internet. iBGP (Internal BGP) runs between routers within the same AS. Key differences: eBGP changes the next-hop by default, iBGP does not. eBGP has a default TTL of 1 (directly connected), while iBGP uses TTL 255. iBGP requires a full mesh topology or route reflectors to prevent routing loops.
Do I need to configure BGP for the CCNA exam?
The CCNA exam tests BGP at a conceptual level only. You should understand what BGP does, when it's used, and basic terminology (AS numbers, eBGP vs iBGP, path attributes). You do not need to configure BGP from scratch for CCNA, but hands-on practice helps build understanding. Full BGP configuration is a core topic on the CCNP ENARSI exam.