Verified: 2026-10-17By Alex Chen (Lead BGP Architect)RFC 4271 & RFC 19979 Min Read

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:

Step 1: Weight (Vendor Local):Highest weight preferred (Local to router, e.g. Cisco).
Step 2: Local Preference (Local-Pref):Highest Local-Pref preferred (Standardized across entire AS).
Step 3: Locally Originated:Routes originated by the local router preferred over learned routes.
Step 4: Shortest AS-Path Length:Shortest sequence of traversed ASNs wins (Where Prepending Operates).
Step 5: Origin Code:IGP (i) < EGP (e) < Incomplete (?)
Step 6: Multi-Exit Discriminator (MED):Lowest MED preferred among routes from the same neighboring AS.
Step 7: eBGP over iBGP:External BGP paths preferred over Internal BGP paths.
Steps 8-10: Tie-Breakers:Lowest IGP metric to next-hop -> Oldest route -> Lowest Router ID.

2. Comparison: AS-Path Prepending vs BGP Communities

Compare the two dominant methods of influencing incoming Internet traffic flows:

Comparative Analysis of Inbound BGP Traffic Engineering Tools
ParameterAS-Path PrependingBGP Communities (RFC 1997)MED (Multi-Exit Discriminator)
Decision PointStep 4 (AS-Path Length)Step 2 (Manipulates Local-Pref)Step 6 (MED)
Upstream CooperationNone required (Universally accepted)Requires upstream ISP community supportOnly respected by direct neighbor AS
Steering ReliabilityModerate (Easily overridden by Local-Pref)Extremely High (Deterministic)Low to Moderate
Recommended SettingPrepend ASN 1 to 3 timesSet Local-Pref to 70 / 80 on backupUsed for multiple links to SAME ISP
Blast RadiusGlobal Internet routing tablesTargeted to specific upstream transitDirect 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:

Cisco IOS Route-Map:route-map RM-BACKUP-OUT permit 10
Cisco Prepend Command:set as-path prepend 64500 64500
Juniper Junos Policy:set policy-options policy-statement PREPEND-BACKUP then as-path-prepend "64500 64500"

4. Practical Diagnostics: Inspecting AS-Path via Looking Glass

Verify how global vantage points perceive your prepended AS-Path:

Query RouteViews BGP Telnet:show ip bgp 198.51.100.0/24
RIPEstat Real-Time Routing Paths:curl -s "https://stat.ripe.net/data/looking-glass/data.json?resource=1.1.1.0/24" | jq '.data.rrcs[0].peers[0].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)