TTR Networks

What is AS_PATH?

Autonomous System Path

AS_PATH (Autonomous System Path) is the BGP attribute that lists every autonomous system a route has passed through on its way to you, newest first.

Every BGP route must carry an AS_PATH: it is a well-known mandatory attribute. When a router sends a route to an eBGP neighbour, it adds its own ASN to the front of the list, so a route originated by AS 64500 and passed on by AS 64501 arrives at its next neighbour as 64501 64500. The rightmost ASN is the origin, the network that announced the prefix in the first place. Routers inside one AS pass the AS_PATH between iBGP peers unchanged. The attribute does two jobs:

  • Loop prevention. A router that sees its own ASN in a received AS_PATH rejects the route, because accepting it would mean the route has already been through this network.
  • Path selection. After LOCAL_PREF (and, on some vendors, weight) and a preference for locally originated routes, BGP prefers the route with the shorter AS_PATH. It counts AS hops, not routers, bandwidth or latency.

In practice you meet AS_PATH all the time. Operators "prepend" their own ASN several times on less preferred links to make those paths look longer and steer inbound traffic, filters use regular expressions over the path (for example, accepting only routes that a customer originated), and ROV checks the origin ASN at the end of it. Two cautions: a shorter path is not necessarily a faster one, and a neighbour's LOCAL_PREF overrides any prepending you do. The path also cannot be trusted on its own, since nothing stops a network inserting false entries. The BGP Fundamentals lesson shows how AS_PATH is built and used in best-path selection, and BGP communities, prepending and RTBH puts prepending to work.

Lessons that use AS_PATH

  • BGP FundamentalsTeaches this term · Intermediate · 75 min

    How the Border Gateway Protocol glues the internet together: autonomous systems, sessions, path attributes, best-path selection, iBGP scaling and a hands-on eBGP lab with real FRR configuration.

  • OSPF FundamentalsBeginner · 70 min

    The link-state IGP that runs inside most networks: neighbour adjacencies, LSA flooding, SPF, costs, DR/BDR, areas and LSA types, a hands-on FRR lab, and how OSPF underpins BGP.

  • RPKI and Route Origin ValidationIntermediate · 70 min

    Cryptographically signed routing origins: the RPKI trust chain, creating safe ROAs, Valid/Invalid/NotFound, validators and RTR, a real FRR + StayRTR lab, and what ROV can't stop (forged origins, leaks), plus where ASPA comes in.

Related terms