What is Anycast? One IP, Many Servers
Anycast is a network addressing method where the same IP address is announced from multiple locations simultaneously. When a client sends traffic to an anycast address, BGP routing delivers it to the nearest announcing location — "nearest" in terms of network topology, not geography, though the two often correlate.
How Anycast Works
In normal unicast routing, each IP address belongs to exactly one server. In anycast, the same prefix is announced from many different locations. BGP treats each announcement as a valid route and selects the best one based on AS path length and local preference.
For example, 1.1.1.1 is announced by Cloudflare (AS13335) from over 300 cities worldwide. When you query 1.1.1.1, your traffic goes to whichever Cloudflare data center BGP determines is closest to your network. Users in Tokyo reach a server in Tokyo; users in London reach a server in London — all using the same IP address.
Where Anycast is Used
- DNS — all 13 DNS root servers use anycast. Public resolvers like 8.8.8.8 (Google) and 9.9.9.9 (Quad9) use anycast.
- CDNs — content delivery networks use anycast to direct users to the nearest edge server.
- DDoS mitigation — anycast naturally distributes attack traffic across many locations, preventing any single site from being overwhelmed.
Anycast and TCP
Anycast works naturally with UDP protocols like DNS, where each query is independent. For TCP-based services (HTTPS), anycast requires more care — a TCP connection must stay at the same server for its duration. This works because BGP routes are usually stable for minutes or hours, and modern implementations use techniques like ECMP flow hashing to keep connections pinned.
Viewing Anycast in the Routing Table
You can observe anycast in action by looking at how a single prefix is visible from multiple paths. Look up any major anycast address to see the AS paths converging on the same origin AS from different directions:
- 1.1.1.1 — Cloudflare anycast DNS
- 8.8.8.8 — Google anycast DNS
- 198.41.0.4 — A root server (anycast)