What is an AS Path?

Published Aug 13, 2026

← All glossary terms Jump to A

The AS path is a BGP path attribute that records, in order, every autonomous system (AS) a route has crossed from its origin to the local router. BGP routers use it to detect routing loops and to influence path selection: administrators can prepend extra AS numbers to make an otherwise attractive route look less preferred to peers.

Key takeaways

  • The AS path lists every autonomous system a BGP route has crossed.
  • Routers discard a route if their own AS already appears in its path.
  • Prepending AS numbers lengthens a path to make peers avoid it.
  • BGP compares AS path length as a tiebreaker in best-path selection.
  • Versa VOS uses AS path prepending to steer traffic toward standby hubs.

On this page: Why it mattersHow it worksAS path segment typesAS path & VersaFAQ

Why is AS path important?

BGP makes routing decisions largely on policy and path attributes rather than bandwidth or latency, and AS path is one of the most consequential. Its length is a tiebreaker in BGP’s best-path algorithm – a shorter AS path is generally preferred over a longer one, all else being equal. Because operators can artificially lengthen it through prepending, AS path becomes a primary traffic-engineering tool: a network with two uplinks can make one look “closer” simply by padding the path advertised out the less-preferred circuit.

AS path also doubles as BGP’s built-in loop-prevention mechanism. BGP has no TTL-based loop detection like interior protocols, so each router checks whether its own AS number already appears in a route’s AS path before accepting it; if it does, the router drops the route, since accepting it would create a loop.

What is AS path?

Every time a BGP route crosses from one autonomous system into another, the receiving border router prepends its own AS number to the front of the route’s AS path before re-advertising it. By the time a route has propagated widely, the AS path reads like a breadcrumb trail: the AS numbers of every network it passed through, ending with the AS that originated it.

A router reads the AS path left to right, closest AS first, using it for two purposes: rejecting a route outright if the local AS is already present, and comparing path lengths against other candidate routes, feeding best-path selection after local preference. Because the AS path is visible and mutable by anyone along the chain, it is one of the few BGP attributes an operator can manipulate directly to change how other networks prefer or avoid a route.

AS path segment types

The AS path attribute is not just a flat list. RFC 4271 defines it as a sequence of segments, each tagged with a type. The two core types are AS_SEQUENCE, an ordered list of ASes a route has actually traversed, and AS_SET, an unordered set used when routes are aggregated into a summary – enough for loop detection without exposing each contributor’s exact path.

BGP confederations split a large AS into sub-ASes without exposing that structure externally, adding two more segment types: AS_CONFED_SEQUENCE and AS_CONFED_SET, which record intra-confederation hops and are stripped before a route leaves the confederation, per RFC 5065. VOS layers its own configuration-level path actions on top of this attribute, described next.

AS path & Versa

VOS devices expose AS path controls throughout BGP configuration on Director: Local AS Mode controls whether AS numbers are inserted or prepended on import and export, and a Loop Count sets how many times the local AS may repeat before the route is discarded. Peer policies can match routes by AS path and apply an AS Path Action – prepend, remove matching AS numbers, or both – through BGP import and export rules. AS Override replaces a neighbor’s AS numbers with the local AS in the path.

Prepending is also a production traffic-engineering tool: SD-WAN–SSE hub integration uses it to make one Versa Cloud Gateway less preferred than another, prepending the local AS once on the active path and twice on the standby path, so customer SSE hubs select the active hub by default and fail over cleanly if it goes down.

Frequently asked questions

What is AS path prepending?

AS path prepending repeats an operator’s own AS number multiple times in a route’s AS path before advertising it. Because BGP prefers shorter paths, the padded route looks less attractive to peers, letting operators steer inbound traffic without changing policy elsewhere.

How does AS path prevent routing loops?

Every BGP router checks a received route’s AS path for its own AS number before accepting it. If the local AS is already listed, the router discards the route, since accepting it would mean traffic looping back through an AS it already crossed.

What is the difference between AS_SEQUENCE and AS_SET?

AS_SEQUENCE is an ordered list recording each AS a route actually traversed. AS_SET is an unordered collection used when routes are aggregated, listing contributing ASes without preserving order – enough for loop detection, not a literal record.

Does a shorter AS path always win in BGP best-path selection?

Not always. BGP evaluates attributes in a fixed order, and AS path length is checked only after local preference. A shorter path wins only if the compared routes are still tied on every earlier attribute.

Can the AS path attribute be falsified?

Prepending is legitimate, but nothing in base BGP cryptographically verifies an AS path reflects the true route. This is why route-origin validation such as RPKI, and path-validation efforts such as BGPsec, exist to catch route leaks and hijacks.

More on AS path

If you want to learn more, these are sources we trust.

RFC 4271: BGP-4 – the AS_PATH attribute RFC 5065: AS Confederations for BGP
The core BGP-4 spec: how AS_PATH is built, compared, and used for loop detection and best-path selection. Defines the segment types confederations use to hide internal structure externally.

If you’re reading about AS path, these are worth looking at next.

Border Gateway Protocol External BGP Internal BGP
The path-vector protocol that builds and exchanges the AS path as routes propagate between autonomous systems. A BGP session between peers in different autonomous systems – where prepending and loop detection do their real work. A BGP session within one autonomous system, where the AS path typically stays unchanged as routes redistribute internally.