Anycast
A routing technique where multiple servers in different locations share the same IP address, and the internet's routing protocols automatically direct users to the nearest one.
Last updated:
What is anycast?
Anycast is a network addressing technique where the same IP address is advertised from multiple geographic locations, and the internet's Border Gateway Protocol (BGP) routes each user's packets to the nearest (by BGP distance) of those locations. The user doesn't know, and doesn't care, which physical server handled their request — they just see one address that happens to be very fast.
Contrast this with:
- Unicast — one-to-one: each IP identifies exactly one host
- Multicast — one-to-many: one sender, a group of identified receivers
- Broadcast — one-to-all on a local network segment
Why anycast matters
Anycast is the backbone of modern internet infrastructure. Almost everything you rely on uses it somewhere:
- Public DNS resolvers — 1.1.1.1 (Cloudflare), 8.8.8.8 (Google), 9.9.9.9 (Quad9) are all anycast. Each of those IPs represents hundreds of datacenters worldwide, and your query lands at the closest one
- Root DNS servers — all 13 "root server letters" (A through M) are anycast, with hundreds of physical instances
- CDNs — Cloudflare, Fastly, and Akamai use anycast for their edge network so requests land at the nearest POP
- DDoS mitigation — an anycast network naturally absorbs DDoS traffic because the load spreads across every POP, instead of concentrating on one datacenter
- Cloud load balancers — AWS Global Accelerator and Google Cloud Global Load Balancing use anycast to route users to the nearest region
How anycast works underneath
Every advertising location announces the same CIDR block into BGP from its own ASN. When another network wants to send traffic to any address in that block, BGP picks whichever of the advertising routes looks shortest according to its configured policy (typically AS path length, local preference, and MED).
One consequence: different users see different "nearest" instances. Two users asking 1.1.1.1 from different continents hit different datacenters. This is also why anycast doesn't work well for long-lived stateful connections — a BGP route change mid-connection can silently shift the destination server and break the TCP session. Anycast is used primarily for stateless protocols like DNS, or with careful session affinity for HTTP and TLS.