What is AS path prepending, and what are its limits?
Show the answer
Say this first
Prepending adds extra copies of my own ASN when I advertise to a neighbor, so that path looks longer and other networks prefer a different one. It is the usual way to make one ISP the backup for inbound traffic. Limits: it only matters where AS path length is the deciding step, so it loses to anyone's local preference; past about three prepends it rarely changes more; and a long prepended path is easier to beat with a shorter fake announcement.
Go deeper
Config
ip prefix-list OUR-PREFIXES seq 5 permit 203.0.113.0/24
!
route-map ISP2-OUT permit 10
match ip address prefix-list OUR-PREFIXES
set as-path prepend 64500 64500
!
router bgp 64500
neighbor 198.51.100.1 route-map ISP2-OUT outISP2 receives the path 64500 64500 64500: two prepends plus the normal one added on eBGP.
Verifying
show ip bgp neighbors 198.51.100.1 advertised-routes on IOS shows the route as it sits in your table, not
the prepended path. Check from the outside: a looking glass in ISP2 or elsewhere, or the peer's
show ip bgp 203.0.113.0.
Rules of thumb
- Prepend only your own ASN. Someone else's ASN in your path makes that AS reject your route as a loop.
- Start with one or two prepends and measure. Long prepend chains mostly make the table bigger.
- Inbound prepending also exists:
set as-path prepend last-as 2on a received route makes your own router like that path less. Local preference is the cleaner tool for that.
They will ask next
You prepend five times toward ISP2 and traffic still arrives on ISP2. Why?
ISP2 itself, and anyone who buys from ISP2, gives customer routes a higher local preference than peer routes. They never compare AS path length. Use ISP2's backup community to lower your route's local preference inside ISP2.
Traps
- Prepending on the primary link instead of the backup.
- Expecting
advertised-routeson IOS to show the prepends.