How BGP Routing & AS-Path Prepending Actually Work

Border Gateway Protocol (BGP-4, RFC 4271) is the routing glue of the global internet. Unlike interior protocols (OSPF, IS-IS) that optimize for link bandwidth or latency, BGP is a policy-driven path-vector protocol connecting ~80,000+ active Autonomous Systems (ASNs).

1. How BGP Selects the Best Path

When a router learns multiple paths to the same IP prefix, it walks a deterministic tie-breaker chain: Local Preference (highest wins for outbound), AS-Path Length (shortest number of ASN hops wins), Origin Type, MED, and eBGP over iBGP.

2. Single-Homed vs. Multi-Homed Resilience

A single-homed ASN relies on one upstream transit provider. If that provider suffers a fiber cut or BGP misconfiguration, the ASN disappears from the internet. A multi-homed ASN peers with two or more independent transit providers (and ideally connects to Internet Exchange Points listed in PeeringDB), giving it automatic failover.

3. AS-Path Prepending & Its Limits

To steer inbound traffic away from a backup link, operators prepend their own ASN multiple times (e.g., 13335 13335 13335). However, because upstream providers often override AS-Path length with Local Preference for direct customers, prepending only influences networks beyond the immediate transit hop.

Try our interactive BGP AS-Path & Communities Decoder →