Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

AS_PATH

Direct 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.

When to use this

Use it when a route is rejected because it already contains your own AS, when prepending does not move inbound traffic the way you expected, or when the path with the shorter AS_PATH still loses.

First 30 seconds

1. show ip bgp <prefix> — AS_PATH per path (leftmost = neighbour AS).

2. Shorter AS_PATH wins after weight, LOCAL_PREF and local origin.

3. A router rejects paths containing its own AS (loop prevention).

Operational verification

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

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Protocol standard + deployed implementation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformProtocol standard · IOS/IOS XE · Cisco IOS XE
Key commandshow ip bgp regexp <regexp>
Scope / prerequisiteUse it when a route is rejected because it already contains your own AS, when prepending does not move inbound traffic …
Reference · 1
What next?3 suggested next steps
Catalog command links1
Evidence1
On this pageJump to a specific section
Verification

Show Commands

Read-only Cisco show commands for confirming state, narrowing a fault and interpreting the current boundary.

Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

6 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 First 30 seconds Verify boundary

Immediate answer: Inspect the full AS_PATH for every candidate prefix and separate loop-prevention from best-path preference.

Verification chain: received UPDATE → policy changes/prepending → AS_PATH → eligibility/loop check → best-path → RIB

Stop condition: A shorter AS_PATH is not automatically best when earlier decision factors or policy already select another path.

Step 2 Operational verification and known-good state Verify boundary
show ip bgp 203.0.113.0 255.255.255.0
show ip bgp regexp _65030$
show ip bgp regexp ^65010_
show ip bgp regexp ^$

The first shows the AS_PATH of every path for one prefix. The regular expressions filter the whole table: _65030$ lists routes originated by AS 65030, ^65010_ routes learned directly from AS 65010, and ^$ routes originated in your own AS. ^ is the start of the path, $ the end and _ a boundary between AS numbers.

Known-good: every path shows the ASes you expect in the order you expect, received paths never contain your own AS, and your prepends are visible on the receiving side.

Step 3 Verification and output interpretation Verify boundary

Inspect AS_PATH for representative prefixes before and after policy. Confirm that the expected peer advertisements contain the intended path and that the local best-path decision actually changed if that was the goal. For inbound-engineering changes such as prepending, verify from a remote or upstream perspective when possible because the local router cannot show how an external AS will rank the advertisement.

Step 4 Verification & troubleshooting Narrow the fault

1. show ip bgp <prefix> → the AS_PATH line above each path.

2. Before concluding that AS_PATH decided, compare Weight and LOCAL_PREF on the paths. Only if they are equal does length matter.

3. To check a prepend, look on the receiving side — the neighbour's show ip bgp <prefix> or a public looking glass. The local advertised-routes view may not show attributes set by an outbound route-map.

4. A route that is missing altogether: check whether its path would contain your own AS; such routes are rejected on arrival and never reach the table.

Step 5 Failure signatures and troubleshooting branches Narrow the fault
  • The shorter AS_PATH loses. An earlier step decided — look at Weight and LOCAL_PREF.
  • Prepending does not move inbound traffic. The upstream prefers the route by LOCAL_PREF, or traffic follows a more specific prefix announced on the other link.
  • Routes from your other site are not received. Both sites use the same AS number; loop prevention drops the routes. Use allowas-in or ask the provider for as-override.
  • A private AS number shows up beyond your provider. It was not removed on the way out; see remove-private-as.
  • An unexpected AS appears in the path. The route takes a different transit than assumed, or someone upstream is leaking it.
Step 6 When the problem is really fixed Narrow the fault
  • Each candidate path shows the expected AS_PATH.
  • You can name the step that decides between the paths — AS_PATH length, or an earlier attribute.
  • Prepends are confirmed on the receiving side.
  • Inbound traffic enters on the intended link (traceroute from outside, interface counters).
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

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.

Key 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).

ReferenceWhat it is2 sections · depth on demand

BGP scope — internal and external paths

AS_PATH exists on internal and external BGP routes. Ordinary eBGP propagation prepends the advertising AS; ordinary iBGP propagation within the AS leaves AS_PATH unchanged. The local ASN in a received path normally prevents inter-AS loops, but an internal reflection loop cannot be detected by AS_PATH alone. iBGP therefore needs its no-relay rule or RR originator/cluster protections. The retained eBGP path-manipulation examples do not imply that AS_PATH is an eBGP-only attribute.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

What it is

AS_PATH is the list of autonomous systems a route has passed through. Every AS adds its own number at the front when it advertises the route to another AS. BGP uses the list for two things: to detect loops, and to compare how long two paths are.

ReferenceWhy it matters1 section · depth on demand

Why it matters

It is the attribute everyone knows — "shortest AS path wins" — and the one most often overestimated. On Cisco it is only checked after Weight, LOCAL_PREF and local origination, so a longer path wins whenever policy says so. Its real strength lies elsewhere: it is one of the few attributes that travel across the whole Internet, which makes prepending the main way to influence how other networks reach you. And its loop-prevention rule explains why some routes are dropped without any message.

ReferenceImportant terms & boundaries7 sections · depth on demand

Key points

  • Toward an eBGP neighbour the sender adds its own AS at the front; over iBGP the list is not changed.
  • Read it right to left: the rightmost AS originated the prefix, the leftmost is the neighbour you learned it from.
  • A router rejects a route from an eBGP neighbour if its own AS is already in the list.
  • Shorter wins — after Weight, LOCAL_PREF and local origination.
  • Length counts autonomous systems, not routers, distance or delay. An AS_SET {…} counts as one.
  • Prepend only your own AS, outbound: set as-path prepend 65000 65000.
  • Match paths with regular expressions: show ip bgp regexp … and ip as-path access-list.

In depth

AS_PATH lists the autonomous systems a route has passed through

Each eBGP speaker prepends its own AS number when it advertises a route. AS_PATH does two jobs: loop prevention (a router rejects routes containing its own AS) and path selection. In Cisco's best path order, shorter AS_PATH is step 4, after weight, local preference and locally originated routes.

R1# show ip bgp regexp _64520$
   Network          Next Hop            Metric LocPrf Weight Path
*>  203.0.113.0/24   192.0.2.5                0             0 64511 64520 i
*                    192.0.2.1                0             0 64510 64530 64520 i
R1(config)# route-map PREPEND-OUT permit 10
R1(config-route-map)# set as-path prepend 64500 64500 64500
R1(config)# router bgp 64500
R1(config-router)# neighbor 192.0.2.9 route-map PREPEND-OUT out

Documented points from Cisco's best path document

PointDetail
AS_SETCounts as one AS, however many it contains
Confederation segmentsNot counted in the length
bgp bestpath as-path ignoreSkips the AS_PATH step (hidden command)

Uses

UseHow
Make an inbound path less preferredPrepend your own AS on that link (above)
Filter routes from or to specific ASesip as-path access-list with regular expressions
Detect a route leakUnexpected ASes in the path

Prepending limits

Prepending affects only networks that compare AS_PATH. Neighbours that set LOCAL_PREF or weight override it. Many providers also prefer customer routes by local preference, so prepending towards a provider changes less than you'd expect. Prepending more than a few times rarely adds anything.

Common regular expressions

ExpressionMatches
^$Routes originated in your own AS
^64510_Learned directly from AS 64510
_64520$Originated by AS 64520
_64520_AS 64520 anywhere in the path

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Platform, version and operating-envelope scope

Cisco IOS / IOS XE first; best-path tie breakers and command output vary by release and feature set.

Quick reference

AS_PATH lists the autonomous systems a route has traversed, newest first. BGP prefers shorter AS_PATHs and drops routes containing its own AS. Operators prepend their own AS several times to make a path less attractive for inbound traffic.

route-map PREPEND-OUT permit 10
 set as-path prepend 65010 65010 65010
router bgp 65010
 address-family ipv4 unicast
  neighbor 192.0.2.1 route-map PREPEND-OUT out
show bgp ipv4 unicast regexp _64500$

Documented example, not captured output.

AS_PATH regular expressions (_64500$ = originated by AS 64500) are useful in filters and show commands.

Mechanics and state ownership

When a router advertises a route to a neighbour in another AS, it puts its own AS number at the front of the list. Inside an AS nothing is added, so the length of the list counts AS hops, not routers. A route you originate yourself has an empty path locally and carries just your AS once it has left.

The same list prevents loops between autonomous systems: a router that finds its own AS in a received path knows the route has already been through its AS and drops it. This is why two sites that use the same AS number and connect through a provider do not accept each other's routes unless allowas-in is configured (or the provider rewrites the path with as-override).

Prepending makes a path look longer by repeating your own AS. It can only make a path less attractive, and only for networks that reach the AS_PATH step with everything else equal. A neighbour that prefers customer routes through LOCAL_PREF will not be moved by any number of prepends, and a more specific prefix announced elsewhere wins before BGP best path is even consulted.

State model and selection mechanics

Each eBGP advertisement normally prepends the advertising AS to AS_PATH, building a path-history attribute as the route crosses AS boundaries. A router normally rejects a route containing its own ASN, providing inter-AS loop prevention. During best-path selection, a shorter AS_PATH is commonly preferred after higher-priority local policy attributes. AS_SET/confederation details can affect interpretation, so the visible string should be read as a BGP policy attribute rather than a literal packet-by-packet physical path trace.

Limits and common misconceptions

AS_PATH length is not physical hop count, latency or bandwidth. An AS may contain a large internal topology, and policy can prepend the same ASN multiple times. A shorter AS_PATH can lose to LOCAL_PREF or other earlier decision criteria, so “shortest AS path should win” is only true when higher-priority attributes do not decide first.

ReferenceConfiguration & state1 section · depth on demand

Policy and configuration model

Use AS_PATH policy deliberately. Prepending the local ASN can make a route less attractive to remote networks, but remote LOCAL_PREF or other upstream policy can override that signal. Filters can match AS sequences for acceptance or advertisement policy; such expressions should be narrowly scoped and documented because an overly broad AS-path regex can affect far more prefixes than intended.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical examples

Configuration & expected output

Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.

Configuration example

Cisco IOS / IOS XE RFC 4271Make the link to 192.0.2.6 less attractive for inbound traffic by prepending the local AS twice

Assumptions: Lab addressing; local AS 65000; eBGP neighbours already Established; route-refresh supported.

route-map PREPEND-OUT permit 10
 set as-path prepend 65000 65000
!
router bgp 65000
 address-family ipv4 unicast
  neighbor 192.0.2.6 route-map PREPEND-OUT out
!
! then: clear ip bgp 192.0.2.6 soft out

Expected output

Cisco IOS / IOS XE RFC 4271show ip bgp 203.0.113.0 255.255.255.0

Expected state: Both paths valid with equal Weight and LOCAL_PREF; the path with one AS in AS_PATH is best.

BGP routing table entry for 203.0.113.0/24
Paths: (2 available, best #1, table default)
  65010
    192.0.2.2 from 192.0.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external, best
  65020 65030 65010
    192.0.2.6 from 192.0.2.6 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, external
! Illustrative output, not captured Evidence.
The line above each next hop is the AS_PATH. Path 1 crosses one AS, path 2 three; LOCAL_PREF is equal, so AS_PATH length decides. Both paths end in 65010, the AS that originated the prefix.
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docProtocol standard + deployed implementation RFC 4271

Authoritative/upstream documentation reviewed for bounded claims in Routing → BGP → eBGP → AS_PATH. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.rfc-editor.org/rfc/rfc4271.html · confidence 94%
Embedded reference data

Quick lookup tables

AS_PATH · routing reference

Compact path-selection and evidence boundaries for fast lookup.

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

AS_PATH operational reference

Topic-specific bounded interpretation: known-good BGP state, suspicious signatures and the next technical proof boundary.

BoundaryKnown-good for AS_PATHSuspicious signatureNext proof
Session/inputCorrect peer, AF and prefix contextTransport, FSM or prefix eligibility disagreesPeer detail and exact prefix
Attribute/policyAS_PATH as both inter-AS loop-prevention state and a policy-visible path attribute whose sequence length and manipulation can influence best-path selection matches intended policyunexpected local-AS loop rejection, excessive or missing prepends, an apparently shorter AS_PATH losing because a higher-priority attribute decided first, policy matching the wrong ASN expression, or operators assuming AS_PATH length represents latency or actual router hopsCompare candidate paths and policy
Route/forwardingExpected best path reaches RIB/FIBBGP state exists but installed path disagreesRIB/FIB/CEF and next-hop proof
ClosureOriginal test passes for explained reasonSymptom moved, was bypassed or state was forcedRegression/failover test
Confirmation

Confirm action

Continue?