AS Path Prepending on XE and XR
This short article explores what happens when you do AS path prepending and apply it outbound to an eBGP neighbor.
Consider the following topology:

R1 originates 10.10.10.10/32 into BGP. R2 uses the following route-map and applies it to the neighbor statement for R3 outbound:
route-map AS_PREPEND
set as-path prepend 100
!
router bgp 65001
neighbor <R3> route-map AS_PREPEND out
What is the AS path for 10.10.10.10/32 as seen on R3? There are two options that might make sense:
100 65001 65000 i
65001 100 65000 i
The answer is 65001 100 65000 i. This is because the route-map is applied before the local AS is finally added to the AS path, when advertising the route to the eBGP peer.

R3#show bgp ipv4 uni | be Network
Network Next Hop Metric LocPrf Weight Path
*> 10.10.10.10/32 10.10.12.1 0 65001 100 65000 i
Note that this is logic is not applicable when you change the next-hop IP address in the route-map. The router doesn’t then change this to its interface address used for the eBGP session. The next-hop that the route-map sets takes precedence.
AS Path Prepending on IOS-XR
This same logic applies when preforming AS path prepending on XR with the following route-policy:
#R2
route-policy AS_PREPEND
prepend as-path 100
end-policy
!
router bgp 65001
neighbor <R3>
address-family ipv4 unicast
route-policy AS_PREPEND out
The local AS is prepended after the RPL prepending takes place:
RP/0/0/CPU0:R3#show bgp ipv4 uni | be Network
Thu Dec 8 04:07:53.213 UTC
Network Next Hop Metric LocPrf Weight Path
*> 10.10.10.10/32 10.2.3.2 0 65001 100 65000 i
Last updated