Articles

What Is Anycast? One IP Address, Many Locations

Anycast announces one IP address from many locations so the network routes each user to a nearby server. How it works and why CDNs and DNS rely on it.

The Lycoris Team The Lycoris Team · · 5 min read
Earth at night from space, city lights glowing across the continents

Anycast is a network addressing and routing technique in which the same IP address is announced from many locations at once, and the internet’s routing system delivers each packet to whichever of those locations is closest in network terms. A user in Tokyo and a user in Madrid can both send traffic to the identical address and reach entirely different servers, without either of them knowing.

It is one of the quiet foundations of the modern internet. Public DNS resolvers, the DNS root servers, and most large content delivery networks rely on anycast to put services close to users and to spread out traffic, including attack traffic.

Unicast, broadcast, multicast, and anycast

IP networking defines several ways of mapping an address to destinations:

Destinations per addressWho receives a packetTypical use
UnicastOneThat single hostAlmost all ordinary traffic
BroadcastAll hosts on a local networkEvery host on the segmentLocal discovery, e.g. DHCP
MulticastA subscribed groupEvery group memberStreaming to many receivers on managed networks
AnycastManyOne host, usually the nearestDNS, CDNs, DDoS absorption

The key distinction is that anycast delivers each packet to one of many possible destinations, while multicast delivers it to all members of a group. From the sender’s perspective, an anycast address looks exactly like a normal unicast address.

How anycast works with BGP

The internet is a network of networks, each called an autonomous system, that exchange reachability information using the Border Gateway Protocol (BGP). Each network tells its neighbours which blocks of IP addresses it can deliver traffic to, and routers pick a best path for each block based on factors such as path length and the operator’s own policies.

To run an anycast service, an operator deploys servers in many data centres and has each site announce the same IP prefix through BGP. Routers across the internet now see several paths to that prefix and, following their normal rules, choose one. Different routers in different places choose different sites.

No special protocol is involved. Anycast is simply what happens when multiple places legitimately claim the same address and BGP does what it always does: pick a best route.

Two consequences follow:

  • “Nearest” means nearest by routing policy, not by geography. BGP prefers paths based on network relationships and hop counts between autonomous systems, not kilometres. A user can occasionally be sent to a more distant site because that is where their ISP’s preferred path leads. Operators tune announcements and peering to keep this rare.
  • Failover is automatic. If a site goes offline and withdraws its announcement, routers converge on the next best path, and traffic flows to another location. The flip side is that a misconfigured announcement can misroute traffic at internet scale, as the Facebook BGP outage of 2021 showed.

Why DNS was anycast’s first big success

DNS is a near-perfect fit. Most DNS queries and responses are single UDP packets, so there is no long-lived connection that could be disrupted if routing shifts. Every location can answer from the same data. And DNS is critical enough that resilience matters enormously.

The DNS root server system uses anycast extensively: each of the root server identities is served from many physical instances around the world. Large public recursive resolvers do the same, which is why a single easy-to-remember resolver address can answer quickly almost anywhere.

Anycast and CDNs

Content delivery networks use anycast to steer users to a nearby edge location without relying entirely on DNS-based geolocation. With DNS steering, the CDN returns different IP addresses depending on where the resolver appears to be, which can be wrong when a user relies on a distant resolver. With anycast, the CDN hands out the same address everywhere and lets routing pick the edge.

Many CDNs combine both approaches, using anycast for its simplicity and resilience and DNS steering for finer-grained control over load.

Anycast as DDoS defence

Anycast changes the arithmetic of a distributed denial-of-service attack. Botnets are spread across the world, so with anycast, attack traffic is naturally split across every site announcing the prefix, with each site absorbing the share routed to it. An attack that would overwhelm a single data centre becomes many smaller floods spread across a global network.

It also contains damage. If one site is saturated, the impact is mostly limited to users routed to that site, and the operator can withdraw the announcement there to shift traffic elsewhere.

The TCP question

The classic objection to anycast is connection-oriented traffic. A TCP connection carries state on a specific server. If a routing change mid-connection sends subsequent packets to a different site, that site has no record of the connection and resets it. The difference between connectionless and connection-oriented protocols is covered in TCP vs UDP.

In practice, internet routes are stable enough over the lifetime of a typical web connection that this is rarely a problem, and large operators run TCP services over anycast routinely. They reduce the risk further with careful traffic engineering and, within each site, with load balancers that consistently map a connection to the same backend. Very long-lived connections are where anycast needs the most care.

Anycast in IPv4 and IPv6

In IPv4, anycast is purely an operational technique: the addresses are ordinary unicast addresses announced from multiple places. IPv6 acknowledges anycast in its addressing architecture, but on the public internet it is deployed the same way, by announcing a prefix from several locations. Because routing works on prefixes, global anycast typically uses prefixes large enough to be accepted by networks’ routing filters rather than single host addresses. If you want to explore how prefix sizes translate into address ranges, the subnet calculator makes the arithmetic concrete.

The takeaway

Anycast announces the same IP prefix from many locations and lets BGP route each user to one of them, usually a nearby one. It gives DNS and CDNs low latency, automatic failover, and a natural way to spread out DDoS traffic, all behind a single address. Remember that nearness is decided by routing policy rather than geography, and that connection-oriented services need stable routing and careful traffic engineering to stay reliable.

Chisato Chisato · · 5 min read

What Is a VPC Endpoint?

A VPC endpoint gives a private network direct access to a cloud service without routing traffic through the public internet or a NAT gateway.

#Cloud #Networking #Infrastructure
Chisato Chisato · · 5 min read

Microsoft 365 Outage November 2026: Cause and Timeline

Outlook, Teams calendars and Copilot failed worldwide for about 30 hours on Nov. 12–13. Microsoft's preliminary cause, timeline and what admins should do.

#Cloud #Microsoft #Infrastructure