An ASN (Autonomous System Number) is a unique number that identifies a network, such as an ISP, hosting company, or large organization, when it exchanges routing information with other networks. That network, called an autonomous system, is a group of IP prefixes run by one or more operators under a single, clearly defined routing policy. The number lets routers and other networks recognize those prefixes as one network.
Each routed IP prefix is announced by an autonomous system, and Regional Internet Registries (RIRs) assign ASNs to network operators. Some website security tools let site owners write rules that match a visitor's ASN, not just the IP address.
How ASNs Work With BGP
- Route exchange: Networks use the Border Gateway Protocol (BGP) to tell each other which IP prefixes they can reach.
- AS path: Each route carries the list of autonomous systems it has passed through. Routers use this list to drop routing loops and to apply policy at the AS level.
- 2-byte and 4-byte ASNs: BGP first carried ASNs as two-octet numbers, with a maximum of 65535. RFC 6793 extended BGP to four-octet ASNs because the two-octet space was running out.
Who Assigns ASNs
- Allocation: IANA allocates ASNs to the five Regional Internet Registries (AFRINIC, APNIC, ARIN, LACNIC, and RIPE NCC). The registries then assign them to network operators under their own policies.
- Private use ranges: 64512 to 65534 and 4200000000 to 4294967294 are reserved for private use. These ASNs must be removed from routes before they are advertised to the global internet.
- Reserved numbers: ASN 0, 65535, and 4294967295 are reserved. The ranges 64496 to 64511 and 65536 to 65551 are set aside for documentation and sample code.