Understanding BGP AS-Path and Route Propagation Across Continents
An engineering breakdown of BGP best-path decision criteria, explaining how network operators utilize AS-Path prepending and BGP communities to manipulate global inbound traffic.
Quick Answer
BGP AS-Path prepending is an inbound traffic engineering technique where an Autonomous System artificially elongates its AS-Path by duplicating its own ASN on secondary upstream links. Because the BGP best-path selection algorithm favors shorter AS-Paths, global Internet routers prefer the shorter, un-prepended primary path.
- Best-Path Criteria: AS-Path length is evaluated at Step 4, immediately after Local Preference.
- Prepend Depth: 2 to 3 prepends are optimal; excessive prepending risks route filtering.
- Local-Pref Override: Upstream carriers using higher Local Preference will ignore AS-Path prepends.
1. The 10-Step BGP Best-Path Selection Hierarchy
When an edge router receives multiple paths toward the same destination prefix, it processes candidates through a standardized decision hierarchy:
2. Comparison: AS-Path Prepending vs BGP Communities
Compare the two dominant methods of influencing incoming Internet traffic flows:
| Parameter | AS-Path Prepending | BGP Communities (RFC 1997) | MED (Multi-Exit Discriminator) |
|---|---|---|---|
| Decision Point | Step 4 (AS-Path Length) | Step 2 (Manipulates Local-Pref) | Step 6 (MED) |
| Upstream Cooperation | None required (Universally accepted) | Requires upstream ISP community support | Only respected by direct neighbor AS |
| Steering Reliability | Moderate (Easily overridden by Local-Pref) | Extremely High (Deterministic) | Low to Moderate |
| Recommended Setting | Prepend ASN 1 to 3 times | Set Local-Pref to 70 / 80 on backup | Used for multiple links to SAME ISP |
| Blast Radius | Global Internet routing tables | Targeted to specific upstream transit | Direct peer only |
Inbound Traffic Steering Method Selection Decision Tree
[ Inbound Traffic Engineering Objective ]
|
+-------------------------+-------------------------+
| |
[ Coarse / Broad Steering ] [ Precision Routing Control ]
Deter traffic from backup link Fine-grained traffic balance
Universal compatibility across ISPs Requires ISP community support
| |
[ AS-Path Prepending ] [ BGP Communities ]
Prepend ASN 2 to 3 times Send vendor community strings
Route advertisement looks longer Sets Local-Pref directly (Step 2)
| |
+-------------------------+-------------------------+
|
[ Best-Path Algorithm Evaluation ]
Step 2: Local-Pref (Overrides Prepends)
Step 4: Shortest AS-Path Length
3. Practical Configuration: Cisco IOS and Juniper Junos
Production router configuration snippets demonstrating standard 2-ASN prepending on a backup transit circuit:
4. Practical Diagnostics: Inspecting AS-Path via Looking Glass
Verify how global vantage points perceive your prepended AS-Path:
Frequently Asked Questions
How does AS-Path prepending make a backup link less preferred for inbound traffic?
In the standard BGP best-path selection algorithm, a shorter AS-Path is strictly preferred over a longer AS-Path (assuming equal Local Preference). By artificially repeating its own ASN multiple times (e.g., AS64500 AS64500 AS64500) in route advertisements sent to a backup ISP, the network makes that path appear longer, inducing distant networks to send inbound traffic via the primary ISP.
Why does AS-Path prepending sometimes fail to steer traffic as expected?
AS-Path prepending fails when an upstream ISP assigns a higher "Local Preference" (Local-Pref) to the prepended route. Because Local Preference is evaluated at Step 2 of the BGP selection algorithm—before AS-Path length at Step 4—any route with higher Local-Pref wins, regardless of how many times the AS-Path was prepended.
How many times should an engineer prepend an ASN?
Best practice is between 1 and 3 prepends (e.g., repeating the ASN twice or three times). Prepending more than 4 or 5 times rarely provides additional benefit, increases packet header overhead, and may trigger route filters on conservative Tier-1 transit backbones.
What is a more effective alternative to AS-Path prepending for traffic engineering?
Using RFC 1997 BGP Communities. Upstream Tier-1 transit providers publish standardized BGP community strings that allow customer networks to directly manipulate the provider's internal Local Preference (e.g. setting Local-Pref to 70 or 80 on specific circuits), guaranteeing predictable traffic steering without relying on AS-Path length heuristics.
Data & Technical Sources
- IETF RFC 4271 — A Border Gateway Protocol 4 (BGP-4 Specification)
- IETF RFC 1997 — BGP Communities Attribute Specification
- IETF RFC 7454 — BGP Operations and Security (Traffic Engineering Guidelines)