Anycast is a routing method where the same IP address is announced from many locations, and BGP routes each user to the nearest one. Public DNS resolvers like 1.1.1.1 and 8.8.8.8, root DNS servers and CDNs use it for speed and resilience.
How it works
How it works
An operator announces the same prefix, say 1.1.1.0/24, via BGP from data centres around the world. Routers pick the shortest path, so a user in Berlin reaches the Frankfurt site and a user in Tokyo the Tokyo site, with the same address.
Why use it
- Speed: answers come from nearby.
- Resilience: if one site goes down, its routes are withdrawn and traffic flows to the next nearest.
- DDoS absorption: attack traffic spreads across all sites instead of hitting one.
Compared with other delivery types
Unicast is one address, one place; multicast is one address, a group of receivers; anycast is one address, many places, one receiver per user.
Why it confuses IP location
Geolocation databases give one location per IP, but an anycast IP is everywhere. That's why 1.1.1.1 might be listed as being in one country while you're talking to a server in your own city.
Examples
$ dig +short CHAOS TXT id.server @1.1.1.1
Cloudflare's resolver answers this query with a short code for the site that served you, based on the nearest airport's code. Ask from another country and you'll get a different site, for the same address.
On a Mac
traceroute 1.1.1.1 from different places ends at a nearby hop with only a few milliseconds of latency, even though the address is the same everywhere.
See it in the app
LightAtom's Map places addresses where their network is registered, and reminds you that CDN and anycast addresses may really be served from much closer.
Frequently asked questions
What is anycast used for?
Public DNS resolvers, root DNS servers, CDNs and DDoS protection: anything that should answer from the nearest of many sites.
Is 8.8.8.8 anycast?
Yes. Google Public DNS, Cloudflare's 1.1.1.1 and Quad9's 9.9.9.9 are all anycast.
What is the difference between anycast and multicast?
Multicast delivers one packet to many receivers. Anycast delivers each packet to one receiver, the nearest of many.
Can anycast work with TCP?
Yes. Routes are stable enough that a TCP connection usually stays with one site; CDNs serve websites over anycast TCP.