Pcornel
Networking · Routing › BGP › BGP Path Selection

AS_PATH

Cheat sheet · https://pcornel.dk/topic.php?topic=1137

Back to the Topic

Answer

AS_PATH lists the AS numbers a route has passed through. BGP prefers the shortest AS_PATH and rejects routes that already contain its own AS, which prevents loops between autonomous systems. Prepending lengthens it to make a path less attractive.

Remember

AS_PATH length is compared only after Weight, LOCAL_PREF and local origination, so prepending can never beat a neighbour's LOCAL_PREF. It counts autonomous systems, not routers, distance or latency, and an AS_SET counts as one.

First checks

show ip bgp <prefix> → AS_PATH on every path (leftmost = neighbouring AS, rightmost = origin AS). show ip bgp regexp _65010_ → every route that passes through AS 65010. To confirm a prepend, look at the path on the receiving side (the neighbour or a looking glass).

Commands

show ip bgp regexp <regexp>
Lists the BGP routes whose AS path matches the regular expression, for example routes from or through one AS.
show ip bgp regexp …
ip as-path access-list
show ip bgp <prefix>

Verify in this order

path received (own AS not in AS_PATH) → inbound/outbound policy (prepend, as-path filter) → Weight, LOCAL_PREF and local origin equal? → shorter AS_PATH wins → best path → RIB → traffic

Where it usually breaks

underlay/interface reachability → protocol adjacency/session → received/originated state → policy → best path/RIB → FIB/adjacency → traffic path

AS_PATH · routing reference

ObservationMeaning
ASN sequenceInter-AS path history
Own ASN presentLoop-prevention trigger by default
PrependingPolicy signal, not physical hops
Shorter pathPreference only after earlier criteria

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=1137

Confirmation

Confirm action

Continue?