Card 06/ 10

ConceptDifficulty: Intermediate2 min

Anycast: One Address in Many Places

Many servers announce the same address, and each packet reaches the nearest one by the routing path.

Anycast means announcing the same IP address range from many places at once, so that each packet for that address reaches whichever site is closest by the internet's routing. Nothing in the address itself says which site will answer; BGP, which chooses paths between networks, sends each user to the nearest copy.

Picture a DNS provider with servers in Frankfurt, Virginia and Singapore, all announcing 192.0.2.0/24 to the internet. A user in Madrid sends a query to 192.0.2.53. Their provider's routers see three paths to that range, and the one through Frankfurt is shortest, so the query lands there. A user in Tokyo, sending to the same address, reaches Singapore.

Three sites announcing one prefix, and each client reaching the nearest

Anycast is different from choosing a site with DNS, where a name returns a different address depending on where the user is. With anycast the address is the same for everyone, and the network itself chooses. The client does nothing special and cannot tell which site answered without asking.

Three properties make it useful. Users reach a nearby site, so round trips are short. A site that goes down stops announcing the range, and traffic shifts to the next nearest within the time BGP takes to update. An attack aimed at the address is spread across every site instead of landing on one.

It suits short exchanges best. DNS queries, a single question and answer, are the classic use: the root servers and most large DNS providers use anycast. CDNs, networks of servers that cache content near users, use it for longer connections too, accepting that a change in routing in the middle of a connection can occasionally send packets to a different site that knows nothing about it.

"Nearest" means nearest by routing, which usually but not always tracks distance. A provider with a poor link may send a user to a farther site.

So when one address answers quickly from everywhere in the world, anycast is usually the reason, and a traceroute from two cities will end at two different sites.