Anycast
How one IP address can be served from many sites at once, how internet routing sends each user to the nearest of them, and why that gives failover, fast DNS and CDNs.
In 30 seconds
Normally one IP address means one machine in one place. With anycast, the same address is set up at many sites, and each site tells the internet’s routers “this address is over here”.
Routers simply follow the shortest route they have heard, so every user lands at a nearby site without knowing others exist. If a site goes down its route disappears and traffic moves to the next nearest.
DNS root servers and content delivery networks rely on this for speed and resilience.
Anycast, step by step
Hops here stand in for BGP’s real choice, which weighs each network’s policy before path length. A route change in the middle of a long connection can break it, though in practice routes are mostly stable.
- Step 1: One address, one place. Normally an IP address belongs to one machine in one place. Every user’s packets travel to that spot, however far away, hop by hop through routers. Distant users wait longer, and if that one site fails the address simply stops answering.
- Step 2: Same address, many places. Anycast breaks the one-place rule on purpose. The operator sets up identical servers at several sites and gives every one of them the very same IP address. From outside it still looks like a single destination; nothing in the address says there are copies.
- Step 3: Every site announces it. Each site tells its neighbouring network “198.51.100.0/24 can be reached through me”, using BGP, the protocol networks use to exchange routes. The news spreads from router to router, so a router can hear several routes to the same addresses. It keeps the one it prefers, normally the shortest.
- Step 4: Routing picks the closest. With every router following its own best route, each user’s packets end up at the site that is closest in routing terms. Three users send to the same address and reach three different machines. Closest means the route the networks prefer, which is usually, but not always, the nearest on a map.
- Step 5: Failover without a switch. If a site fails or is taken down for maintenance, its announcement is withdrawn and routers drop that route. The next-best route takes over, and traffic flows to another site, typically within seconds to a few minutes. Users keep using the same address and change nothing.
- Step 6: DNS runs on anycast. DNS is the classic use. The internet’s root name servers have just 13 addresses (named a to m), yet each is announced from many sites, well over a thousand in total. A lookup is one short question and one short answer, so it does not matter which site happens to reply.
- Step 7: CDNs, and sharing a flood. Content delivery networks (CDNs) use the same trick so that pages and video are served from a site near each visitor. It also spreads load: every site receives only the traffic of its own neighbourhood, so a flood aimed at the address, such as a denial-of-service attack, is divided among all sites instead of landing on one.
Try it yourself
Learn this first
Spotted a mistake on this page?