AS-Path Prepending Is Not a Guarantee: Understanding Internet BGP Traffic Engineering

AS-path prepending is a request, not a command. When you add your own AS number three extra times to the routes you send ISP B, you are asking the rest of the Internet to prefer ISP A. Every network that receives that route is free to ignore the request, and many of them will, for reasons that have nothing to do with you.

The pattern is familiar. An enterprise or content network has two upstream providers. Inbound traffic is lopsided, so someone applies a prepend on the busy link and waits. Sometimes traffic shifts as planned. Often it moves a little, then stops. Sometimes it barely moves at all, and the next instinct is to prepend more.

This article explains why that happens. It covers where AS-path length sits in BGP route selection, the provider policies that outrank it, why more prepending stops helping, and the tools that give you more predictable control over inbound traffic.

AS-path length only matters when a router has already failed to choose a route on something it values more. Prepending makes a path look longer. It does nothing until a remote router reaches the AS-path step of its decision process with two or more candidate routes still tied.

Implementations differ in detail, but the common order for choosing between routes to the same prefix looks like this:

  1. Weight (Cisco-specific, local to one router)
  2. LOCAL_PREF, set by the receiving network’s own policy
  3. Locally originated routes
  4. AS-path length, the step prepending affects
  5. Origin code (IGP, EGP, incomplete)
  6. MED, usually compared only between routes from the same neighbouring AS
  7. eBGP over iBGP
  8. Lowest IGP metric to the next hop, the basis of hot-potato routing
  9. Tie-breakers such as oldest route, lowest router ID or lowest neighbour address

Two things follow from that order. First, any network that sets LOCAL_PREF differently for your two paths has decided before AS-path length is ever consulted. Second, prepending works on routers you do not own, under policies you cannot see. You can make the route less attractive, but you cannot make anyone choose the alternative.

A useful mental model: you control what you advertise; you only influence what others select.

2. Why Remote Networks Ignore Your Prepend

The biggest reason is money. Most providers set LOCAL_PREF by business relationship: routes learned from paying customers rank highest, then settlement-free peers, then transit providers. This ordering is often described as the Gao-Rexford model, and it is widely used, though provider policy varies (Princeton COS 461).

That has a direct consequence for a dual-homed network. ISP B learns your prefix directly from you, so to ISP B it is a customer route. Any copy of the same prefix that arrives through ISP A is a peer or transit route. When ISP A is a peer or a provider of ISP B, that copy carries a lower LOCAL_PREF, and ISP B chooses the direct customer route however many times you prepend. ISP B’s single-homed customers follow ISP B’s choice. Multihomed customers of ISP B apply their own policy and may pick another upstream.

The IETF GROW working group’s draft on prepending makes the same point. It warns that some neighbours always prefer customer routes and that operators should check with them before relying on prepending (draft-ietf-grow-as-path-prepending).

What the remote network does Step that decides Effect of your prepend
Ranks customer routes above peer and transit routes LOCAL_PREF None for that network or anything routing through it
Sets LOCAL_PREF by cost, region or measured performance LOCAL_PREF None
Receives a more-specific prefix on the other path Longest-prefix match in forwarding None where the more-specific is accepted: it wins forwarding over the covering prefix
Sees both paths at equal preference, different lengths AS-path length Works as intended
Already sees a much longer path via ISP A AS-path length A small prepend only narrows the gap and may not reverse it
Sees equal-length paths after your prepend Later best-path steps (origin, MED, eBGP over iBGP), possibly IGP cost to the next hop Outcome depends on the remote network’s topology

Prepending is effective where competing routes are still eligible after higher-priority policy, so path length can decide: the fourth row, and sometimes the fifth. It cannot override a higher LOCAL_PREF or a more-specific route, and you usually cannot see which row a given network falls into.

Academic measurement backs this up. A 2020 IMC study found that prepending is applied to more than a quarter of IPv4 prefixes, but that how well it works depends on where the AS sits in the routing system and how many upstreams it has (Marcos et al., IMC 2020).

3. Worked Example: Three Prepends, Little Movement

An enterprise, AS 64500, announces 203.0.113.0/24 to two providers. ISP A (AS 64501) is a regional provider. ISP B (AS 64502) is a large global carrier with many customers of its own. Roughly 70% of inbound traffic arrives on the ISP B link, so the team prepends 64500 three times on announcements to ISP B and expects traffic to move towards ISP A.

Assumptions. ISP A and ISP B are not customers of each other: they peer, or reach each other through transit. ISP B ranks customer routes above peer and transit routes. If ISP A were a customer of ISP B, ISP B would see both paths as customer routes with equal LOCAL_PREF, and path length could decide.

Only the networks that saw both paths at equal preference moved. Traffic from networks that kept relying on ISP B did not, because ISP B chose the route at LOCAL_PREF before path length was ever compared.

What each group of remote networks did:

  • ISP B and its single-homed customers kept using the ISP B link. To ISP B, the enterprise is a paying customer, and customer routes outrank anything learned via ISP A. Multihomed customers of ISP B follow their own policy and may arrive another way.
  • Networks that peer with both ISPs moved to ISP A. They gave both paths the same LOCAL_PREF, so the shorter AS path won.
  • ISP A’s customers were already arriving via ISP A and did not change.

If ISP B’s customers are the source of most of the traffic, the split barely changes. Adding three more prepends would not help, because the remaining traffic is not decided by path length. A better next step is a tool that acts on ISP B’s own LOCAL_PREF, such as a provider community, or a more-specific announcement on ISP A.

4. Configuration Example: Prepending on Cisco IOS XE

The example’s prepend is three lines of route-map on the session to ISP B. The session to ISP A carries no prepend. Addresses use documentation ranges: ISP B’s neighbour is 192.0.2.1 and ISP A’s is 198.51.100.1.

ip prefix-list PL-OUR-PREFIX seq 10 permit 203.0.113.0/24
!
route-map RM-TO-ISP-B permit 10
 match ip address prefix-list PL-OUR-PREFIX
 set as-path prepend 64500 64500 64500
!
route-map RM-TO-ISP-A permit 10
 match ip address prefix-list PL-OUR-PREFIX
!
router bgp 64500
 neighbor 192.0.2.1 remote-as 64502
 neighbor 198.51.100.1 remote-as 64501
 !
 address-family ipv4 unicast
  network 203.0.113.0 mask 255.255.255.0
  neighbor 192.0.2.1 activate
  neighbor 192.0.2.1 route-map RM-TO-ISP-B out
  neighbor 198.51.100.1 activate
  neighbor 198.51.100.1 route-map RM-TO-ISP-A out
 exit-address-family

Prerequisites. The network statement originates 203.0.113.0/24 only if that exact prefix is in the local routing table, for example through a static route to Null0. The example also assumes Layer 3 connectivity to both providers is already in place. All ASNs, prefixes and addresses are documentation values (RFC 5398 and RFC 5737), not for production use.

Each route-map ends with an implicit deny, so only 203.0.113.0/24 is advertised to either provider. Apply the change without resetting the session:

clear ip bgp 192.0.2.1 soft out

Verify locally that the prefix is still advertised to ISP B:

show ip bgp neighbors 192.0.2.1 advertised-routes

Depending on platform and release, this output may not show the prepended path, because prepends are added as the update is sent. Confirm the path from outside.

Verify remotely from ISP B’s looking glass, or a route collector that peers with ISP B:

show ip bgp 203.0.113.0/24

ISP B should show the path as 64500 64500 64500 64500. A network that peers with both ISPs should now list the path via ISP A, 64501 64500, as best. If ISP B still marks the direct route as best, that is the LOCAL_PREF decision described above, not a configuration fault.

Three configured prepends put four copies of 64500 in the path, because the router adds its own ASN once more when it sends the update:

Observation point AS_PATH Length
ISP A receives the enterprise route 64500 1
ISP B receives the enterprise route 64500 64500 64500 64500 4
Remote AS receives it via ISP A 64501 64500 2
Remote AS receives it via ISP B 64502 64500 64500 64500 64500 5

5. Why More Prepending Stops Helping

Each prepend only affects the networks still comparing path length. One more prepend might move a lot of traffic, a little, or none, depending on how many networks sit exactly at that margin. In practice the early prepends usually matter most. Beyond a few, most networks still using ISP B are doing so because of LOCAL_PREF or a more-specific route, and extra prepends will not change their decision.

The GROW draft says prepending more than five times rarely helps. It also notes the Internet is typically about five ASes deep, so additional prepending generally gives diminishing returns, although longer alternative paths do exist (draft-ietf-grow-as-path-prepending).

Heavy prepending also has costs:

  • Easier hijacks. A route padded with ten copies of your ASN makes a forged, shorter path more competitive. Whether a hijack succeeds still depends on the other routes networks see and on their validation policies.
  • Bigger leak impact. When a route prepended towards every provider is leaked, the leaked copy often looks shorter than the legitimate one and spreads widely.
  • Unexpected shifts. Other networks upstream may prepend too. Stacked prepends can de-prefer a path nobody meant to de-prefer.
  • Filtering. Some operators drop routes with very long AS paths. An extreme prepend can make your backup path invisible exactly when you need it.
  • No effect in some cases. Prepending when single-homed gains nothing. Prepending equally towards every upstream generally creates no preference between them and adds unnecessary risk.

RPKI does not close this gap on its own. Route Origin Validation checks that the origin AS is authorized to announce the prefix. It does not check the rest of the AS_PATH, so a forged path that ends in your real ASN still validates. The GROW draft recommends ASPA objects in RPKI to help verify AS_PATH and detect leaks. ASPA complements origin validation by checking declared provider relationships, which catches many route leaks and some forged paths. It is not complete validation of every AS_PATH.

If one or two prepends have not moved the traffic, investigate the routing policies and competing path lengths of the networks that matter most to you before adding more.

6. Tools That Give More Predictable Control

The most effective inbound tools act at the LOCAL_PREF step or before it, not after it. Prepending still has a place, but it works best alongside these.

Tool What it changes Reach Trade-off
Provider action communities Your provider’s own LOCAL_PREF, prepends or export for your route Inside that provider and towards the peers it names Only as good as the provider’s published community set; values differ per provider
More-specific prefixes Which path wins by longest-prefix match Networks that accept and install the route Adds routes to the global table; needs matching RPKI ROAs; IPv4 longer than /24 and IPv6 longer than /48 are widely filtered
Selective advertisement Which prefixes are reachable on which link Networks that accept and install the route Keep the covering aggregate on both links, or you lose failover
AS-path prepending Path length at the networks still tied after LOCAL_PREF Partial, unpredictable Weak against customer-preference policies; risk grows with count
MED Entry point into one neighbouring AS That neighbour only Not transitive; only useful with multiple links to the same provider
LOCAL_PREF on your own routers Your outbound path Your network Fully in your control, but only for outbound traffic

Provider communities are usually the strongest lever. Many transit providers publish BGP communities that let a customer lower the provider’s LOCAL_PREF for a route, prepend only towards specific peers, or stop announcing to named peers or regions. A lower-preference community on ISP B can address the problem in the worked example, because it acts on ISP B’s own decision at the step that matters. That depends on three things: ISP B supports the community, ISP B has an eligible alternative route, and the value it sets is low enough. Some providers’ lower-preference communities still keep customer routes above peer routes, which would not move this traffic. RFC 8195 shows how such action communities are commonly structured, and cautions operators about communities that decrease LOCAL_PREF because they can lead to unintended stable states known as BGP wedgies.

More-specifics win, but carry obligations. If you announce 198.51.100.0/24 on ISP A and only the covering /23 on ISP B, the /24 attracts traffic from every network that accepts it, regardless of LOCAL_PREF or path length. Publish ROAs that cover the more-specifics, keep the aggregate on both links for failover, and do not split beyond what you need.

Outbound is the easy half. LOCAL_PREF gives you deterministic preference among the eligible BGP paths in your own AS, as long as your routing policy is consistent and the routes are available. Inbound traffic is the half that other networks decide, which is why it needs the tools above.

7. Measure, Don’t Assume

A routing change is only done when you have seen what the Internet did with it. Control-plane views tell you which path networks chose; data-plane views tell you how much traffic actually moved. You need both.

  1. Baseline first. Record inbound traffic per link and by source ASN for at least a full weekly cycle, using NetFlow, IPFIX or sFlow.
  2. Find the networks that matter. Usually a small number of source ASNs send most of your inbound traffic. Those networks’ policies decide your outcome; the long tail does not.
  3. Check their view of you. Use the looking glasses of your providers and of large networks, and public route collectors such as RIPE RIS and RouteViews, to see which path they select before and after the change.
  4. Change one thing at a time. Apply a single prepend or community, then wait for convergence and a comparable traffic period.
  5. Compare by source ASN, not just by link. If a top source ASN did not move, find out why: it is probably a customer of the provider you are trying to avoid.
  6. Write down the result. Record what moved, what did not, and the likely reason, so the next change starts from evidence.

If a key source network still uses the link you wanted to drain, ask your provider. They can tell you how they rank your route and which communities they support.

8. Design Guidance

Treat inbound traffic engineering as influence, and size the design so it still works when the influence fails.

  • Define the goal first. Drain a link, keep a link as backup only, or balance roughly? Each calls for a different tool.
  • Ask each provider for its community guide before turning to prepending.
  • Start with one prepend, measure, then decide. Stop at two or three. If that has not worked, change tools, not the count.
  • Prepend only your own ASN, and only towards the providers you want to de-prefer.
  • Do not prepend when single-homed or equally towards every upstream.
  • Keep the aggregate on every link when you use more-specifics or selective advertisement, and keep ROAs in step.
  • Size each link for the traffic it may get, not the traffic you asked for. If ISP B’s customer cone will always arrive on ISP B, that link must carry it, whatever your policy says.

Architect’s note: traffic engineering is not capacity planning. Prepending should never stand in for adequate Internet edge capacity. Check circuit utilization under normal operation and under defined failure scenarios, and at a minimum validate N-1: the remaining circuits must carry the required traffic after losing one circuit or provider. Where the business requires it, also test multiple simultaneous failures, shared infrastructure dependencies and the loss of a whole Internet edge site. If the design relies on remote networks honouring your prepends to avoid congestion, it depends on something you do not control.