Understanding BGP AS Paths
The AS path is one of the most important attributes in BGP. It records the sequence of autonomous systems that a route advertisement has traversed, serving as both a road map for traffic and a loop-prevention mechanism.
How to Read an AS Path
An AS path is a list of AS numbers separated by spaces. For example:
13335 2914 15169
This path reads left to right, from the observer toward the destination:
- AS13335 (Cloudflare) — the first AS after the route collector
- AS2914 (NTT) — an intermediate transit network
- AS15169 (Google) — the origin AS, the rightmost number, which is the network that owns the IP prefix
The rightmost AS is always the origin — the network announcing the prefix. The leftmost AS is the neighbor of the route collector that received the announcement. Everything in between represents the transit path.
Why AS Paths Matter
AS paths serve several critical functions:
Loop Prevention
BGP's fundamental loop-prevention mechanism is simple: if a router receives a route with its own AS number already in the path, it rejects the route. This prevents routing loops where traffic circles between networks endlessly.
Path Selection
When a router receives multiple routes to the same prefix, the AS path length is a key factor in choosing the best route. All else being equal, shorter AS paths are preferred because they represent fewer network hops. A route with the path 2914 15169 (2 hops) would generally be preferred over 3356 2914 15169 (3 hops).
Routing Policy
Network operators can filter routes based on AS paths. For example, a network might reject routes that pass through a specific AS, or prefer routes through certain transit providers.
AS Path Prepending
AS path prepending is a technique where a network intentionally adds its own AS number to the path multiple times. For example, instead of announcing a prefix with the path 15169, Google might announce it as 15169 15169 15169.
Why? Because other networks prefer shorter paths, prepending makes a route look "longer" and therefore less attractive. This is commonly used for traffic engineering — for example, to make traffic prefer one upstream link over another.
When you look up an IP address and see repeated AS numbers in the path, that is prepending in action.
Special AS Path Attributes
AS_SET
Sometimes you will see AS numbers enclosed in curly braces, like {15169 13335}. This is an AS_SET, used in route aggregation when a single announcement summarizes prefixes from multiple origin ASes. The AS_SET indicates that the aggregated route covers prefixes from all the listed ASes.
AS_CONFED_SEQUENCE and AS_CONFED_SET
These are used within BGP confederations — large autonomous systems that are subdivided into smaller internal sub-ASes for scalability. Confederation AS numbers are typically stripped when routes are advertised externally.
Analyzing AS Paths
When you look up an IP address in a BGP looking glass, the route table often shows multiple routes from different vantage points. Comparing the AS paths reveals:
- Route diversity — How many different transit paths exist to the destination
- Common transit providers — Which ASes appear in most paths (these are major backbone networks)
- Prepending — Repeated AS numbers indicating traffic engineering
- Path asymmetry — The path from A to B is often different from B to A
Explore AS Paths
Try looking up these addresses and examine the AS paths in the route table: