... LIVE
🗺️ Paste BGP AS Path(s) — space-separated AS numbers
Path A (primary / only path)
Enter a valid AS path (space-separated numbers).
Example: 174 1299 65001  |  Paste from: show ip bgp, show route, show bgp
Path B (optional — for comparison)
Leave blank to analyze Path A only
AS Path Length (Path A)

Sources & Methodology

BGP AS path rules from RFC 4271 (BGP-4) and RFC 6996 (Private AS Numbers). Best path selection algorithm from RFC 4271 Section 9.1.2.
📘
RFC 4271 — A Border Gateway Protocol 4 (BGP-4)
Primary BGP standard defining AS path attribute (type 2), best path selection algorithm (Section 9.1.2), and AS path loop prevention. Source for AS path length comparison in best path selection.
📄
RFC 6996 — Autonomous System (AS) Reservation for Private Use
Defines private AS number ranges: 64512–65534 (16-bit) and 4200000000–4294967294 (32-bit). Used for private AS detection in the calculator.
Methodology: AS Path Length = total count of AS numbers (including prepend duplicates) Unique ASes = count of distinct AS numbers in path Prepend count = AS path length - unique ASes Origin AS = rightmost AS in path. Originator AS = first AS (leftmost) = peer who sent route. Private AS detection: 64512–65534 (16-bit) and 4200000000–4294967294 (32-bit). BGP prefers shorter AS path (step 4 of best path algorithm, after weight, local-pref, and local origin).

Last reviewed: April 2026

How Does BGP AS Path Work?

The BGP AS path is a mandatory path attribute (type 2) that records the sequence of Autonomous System numbers a route traverses. It serves two critical purposes: loop prevention (a router discards routes containing its own AS number) and route selection (shorter AS paths are preferred when all other attributes are equal).

AS Path read right-to-left: Origin AS ← Transit AS ← Neighbor AS ← Your router
Example path: 174 1299 65001
Your router received this route from AS 174 (Cogent).
Cogent received it from AS 1299 (Telia).
Telia received it from AS 65001 (the originating network).
AS path length = 3 • Unique ASes = 3 • No prepending detected

AS Path Prepending Explained

Prepending is the technique of adding your own AS number multiple times to make a path appear longer and therefore less attractive for inbound traffic. A route advertised with path 65001 65001 65001 65002 (length 4) is less preferred than the same route via a different peer with path 65001 65002 (length 2). This is the most common BGP inbound traffic engineering technique.

AS PathLengthUnique ASesPrepend CountBGP Preference
65001 65002220Most preferred
65001 65001 65002321Second
65001 65001 65001 65002422Third
174 1299 65001 65002440Also third (equal length)

BGP Best Path Selection — Step by Step

BGP evaluates path attributes in strict priority order to select the best path to a destination prefix. AS path length is step 4 in the process, meaning Weight, Local Preference, and locally originated routes take precedence:

#AttributePreferenceScope
1WeightHighest winsCisco-only, local router
2Local PreferenceHighest winsWithin AS (iBGP)
3Locally originatedLocal winsnetwork/redistribute vs iBGP
4AS Path LengthShortest winsAll BGP peers
5Origin codeIGP > EGP > ?How route entered BGP
6MEDLowest winsBetween same AS peers
7eBGP over iBGPeBGP winsRoute source type
8IGP metric to next-hopLowest winsInternal path cost
💡 Private AS stripping: When ISPs advertise routes to peers or customers, they use neighbor x.x.x.x remove-private-as to strip private AS numbers (64512–65534) from AS paths before advertising them. Without this, private ASes would leak into the global routing table, causing routing issues. The calculator flags private ASes so you can verify they are stripped before external advertisement.
Frequently Asked Questions
A BGP AS path is the list of Autonomous System numbers a route has traversed from its origin. It is a mandatory path attribute (type 2) in BGP. Read right to left: the rightmost AS originated the route, each AS to the left added itself when advertising onward. Used for loop prevention and route selection — shorter paths are preferred.
AS path length is step 4 in the BGP best path selection algorithm. When Weight, Local Preference, and local origination are equal, BGP prefers the route with the shortest AS path. A 3-hop AS path is preferred over a 5-hop path to the same destination. This is why AS path prepending works — artificially lengthening the path makes it less preferred.
Prepending adds your own AS number multiple times to make a path appear longer and less preferred for inbound traffic. If you advertise path 65001 65001 65001 65002 to one peer and 65001 65002 to another, traffic prefers the shorter path. This is the most common BGP inbound traffic engineering technique. Too much prepending (more than 3x) can cause some ISPs to ignore the route entirely.
AS path length counts all AS numbers including duplicates from prepending. Unique AS hops counts only distinct ASes. Path 64500 64500 64500 65001 has length 4 but only 2 unique ASes. BGP uses total AS path length (including prepend duplicates) for best path selection, not unique ASes. This distinction matters when analyzing prepending.
Private AS numbers are reserved for private use and should not appear in the global Internet routing table. Ranges: 64512 to 65534 (16-bit) and 4200000000 to 4294967294 (32-bit, RFC 6996). ISPs strip private ASes before advertising to peers using remove-private-as. Private ASes are commonly used in enterprise CE-to-PE BGP, MPLS VPNs, and internal lab environments.
In Cisco IOS: show ip bgp x.x.x.x/y. In Juniper JunOS: show route x.x.x.x/y detail. The AS path is shown in the output. Read right to left: the rightmost AS is the origin. Each AS to the left represents a transit network that passed the route. The leftmost AS is the peer that advertised the route to you.
AS path regular expressions match routes based on their AS path for filtering and policy. Common patterns: .* matches any path, ^$ matches locally originated routes, ^65001_ matches directly from AS 65001, _65001$ matches routes with AS 65001 as origin, _65001_ matches routes that passed through AS 65001. Used in Cisco (ip as-path access-list) and Juniper (as-path policy).
BGP best path selection order: 1. Highest Weight (Cisco-specific), 2. Highest Local Preference, 3. Locally originated routes, 4. Shortest AS path, 5. Lowest origin code (IGP over EGP over Incomplete), 6. Lowest MED, 7. eBGP over iBGP, 8. Lowest IGP metric to next-hop, 9. Oldest eBGP route, 10. Lowest router ID. AS path is step 4 — weight and local preference override it.
A BGP route reflector re-advertises iBGP routes to other iBGP peers, avoiding full-mesh iBGP requirements. Route reflectors add Originator ID and Cluster List attributes for loop prevention but do NOT modify the AS path. The AS path only changes when a route crosses an AS boundary via eBGP. Within an AS, the AS path remains unchanged regardless of how many route reflectors it passes through.
A BGP confederation splits a large AS into multiple sub-ASes using private AS numbers to reduce iBGP full-mesh complexity. Sub-ASes run eBGP between each other but appear as a single AS externally. Confederation member AS numbers appear in the AS path within the confederation but are stripped when routes are advertised outside it, maintaining the appearance of a single AS to external BGP peers.
Related Calculators
Popular Calculators
🧮

Missing a Networking Calculator?

Can’t find the networking calculator you need? Tell us — we build new ones every week.