What is AS Path?
A BGP path attribute that lists the sequence of autonomous system numbers a route has passed through, used for loop detection and path selection.
The AS Path is a mandatory transitive BGP attribute that records the ordered list of autonomous system numbers a route has traversed from its origin to the current router. When a BGP speaker advertises a route to a neighbor in a different AS, it prepends its own AS number to the beginning of the path. This list is updated hop by hop as the route propagates across the internet. The AS Path serves two primary functions: loop detection and path selection.
For loop detection, a BGP router that receives a route update containing its own AS number in the AS Path will drop the update, preventing the routing information from cycling. For path selection, BGP prefers routes with shorter AS Path lengths, assuming all other attributes are equal. Network operators can artificially lengthen the AS Path using AS Path prepending, which appends copies of their AS number to influence inbound traffic patterns. The attribute is stored as a sequence of 2-byte or 4-byte AS numbers, with the most recent addition at the leftmost position.
In the larger internet routing stack, the AS Path is a key tool for enforcing routing policies between autonomous systems. It works alongside other BGP attributes such as Local Preference, MED, and Communities to control traffic flow. Unlike IGP metrics that reflect link costs, the AS Path abstracts inter-domain topology into a simple hop count, making it both a loop-prevention mechanism and a coarse metric for best-path selection in the global routing system.
Key facts
- Mandatory transitive BGP attribute present in every BGP update.
- Prevents routing loops by rejecting routes containing the receiver's ASN.
- Shorter AS Path is preferred in BGP best-path selection algorithm.
- AS Path prepending artificially increases path length for traffic engineering.
- May contain AS_SET for aggregation or AS_CONFED_SEQUENCE in confederation deployments.
How it works in practice
Related terms
References
More in Networking & Routing
Anycast
Anycast is a network addressing and routing method where a single IP address is assigned to multiple servers, and routers send traffic to the nearest server based on routing protocol metrics.
ASN
A globally unique 16 or 32 bit number assigned to an autonomous system for use in BGP routing between organizations on the Internet.
Autonomous System
An Autonomous System (AS) is a group of IP networks under a single administrative routing policy, identified by a unique ASN (Autonomous System Number) for exterior gateway routing.
BGP
BGP (Border Gateway Protocol) is the path vector routing protocol that networks use to exchange reachability information between autonomous systems on the public internet.
CIDR
CIDR (Classless Inter-Domain Routing) is a method for allocating IP addresses and routing packets using variable-length subnet masks (e.g., /24) instead of fixed classful boundaries.
Hop
A hop is one passage of a packet through a router or other layer-3 forwarding device as it travels from source to destination across an internetwork.
IPv4
IPv4 is the core Internet Protocol using 32-bit addresses, providing roughly 4.3 billion unique identifiers for network interfaces on the global internet.
IPv6
IPv6 is the most recent version of the Internet Protocol, using 128-bit addresses to provide an effectively unlimited number of unique identifiers for networked devices.
Latency
Latency (or round-trip time, RTT) is the time required for a packet to travel from a source to a destination and back, measured in milliseconds, and is a critical metric in network performance.
Looking Glass
A looking glass is a public web-based tool that provides read-only access to a network's BGP routing table, ping, and traceroute diagnostics from that network's perspective.