Quick Summary
- Anycast advertises the same IP address over BGP from many physical locations at once, and routing delivers each user to the topologically nearest one
- It contrasts with unicast (one IP = one host), broadcast (one-to-all on a subnet), and multicast (one-to-a-group)
- Benefits are lower latency, load spread across sites, and automatic failover, which is why DNS resolvers like 8.8.8.8 and 1.1.1.1 and CDNs all use it
The Pizza Chain Hotline Analogy
Picture a big pizza chain with a single, memorable phone number printed on every box and billboard. You dial that one number from anywhere in the country, but you do not reach some distant headquarters — the call is automatically connected to the nearest branch to wherever you are standing. Same number for everyone, but the call lands at whichever store is closest.
That is anycast. Anycast is an addressing and routing technique where the same IP address is advertised (announced over BGP, the internet's routing protocol) from multiple physical locations at once. When you send packets to that address, the internet's routing delivers them to the topologically nearest instance — the one reachable by the best path, the fewest BGP hops — without you doing anything special.
Compare this with the ordinary case, unicast, where one IP maps to exactly one specific host in one place, so every user must reach that single machine no matter how far away it is. (Two other modes round out the picture: broadcast sends one-to-all on a local subnet, and multicast sends one-to-a-group of interested receivers.)
The payoff is threefold: lower latency because you reach the nearest server, load distribution because users naturally spread across sites, and built-in resilience — if a site goes down, BGP withdraws its route and traffic reroutes to the next-nearest site automatically.
Anycast vs Unicast at a Glance
The difference is easiest to see side by side. The same destination IP behaves very differently depending on whether it is advertised from one site (unicast) or many (anycast):
Anycast vs Unicast Routing
One IP, 203.0.113.10, is being advertised. Toggle between unicast (one site) and anycast (many sites), then pick a user location to see where the packets land and how far they travel. In anycast mode, try taking a site offline to watch automatic failover.
Distances and hop counts are illustrative only — they show the pattern, not real-world measurements.
The simulator above makes the core idea concrete: in unicast, every user trudges to the one server no matter how distant. In anycast, the same address is everywhere, so each user lands on the nearest copy — and when a site disappears, the rest seamlessly pick up the slack.
How Anycast Works, Step by Step
The Same IP Is Announced from Many Sites
With anycast, several physically separate servers (in different cities or continents) all advertise the identical IP prefix into the internet using BGP. To the rest of the world, it looks like one destination that happens to be reachable through many doors. Nothing about the IP itself is special — the magic is that more than one place claims it.
Routing Picks the Nearest Door
When your packets head for that IP, every router along the way runs BGP's best-path selection and forwards toward the instance that is topologically nearest — the one with the best route, often the fewest AS hops. Different users, sitting in different parts of the network, are naturally steered to different sites. You never choose a site; the routing does it for you.
A Site Failing Triggers Automatic Failover
If one site crashes or is taken down for maintenance, it simply stops advertising the prefix, so BGP withdraws that route. Routers recompute the best path and the users who were hitting that site now flow to the next-nearest one — usually within seconds and with no DNS change or client reconfiguration. Resilience is baked into the design.
Best for Stateless, Short-Lived Traffic
Anycast shines for stateless or short-lived request/response traffic like DNS lookups and many HTTP requests, because each exchange is self-contained. If routing shifts mid-session, a client could be steered to a different instance — fine for a quick DNS query, trickier for a long stateful connection. That is why anycast is paired with stateless protocols or careful session handling.
Anycast in the Real World
Anycast is one of the quiet workhorses of the internet. Here is where you meet it every day:
DNS Root & Public Resolvers
Each of the 13 DNS root server "letters" is anycast, served by hundreds of physical instances around the
globe under a single address. Public resolvers like 8.8.8.8 (Google) and 1.1.1.1
(Cloudflare) are anycast too — you query one IP, but you reach whichever site is closest to you.
CDNs
Content delivery networks use anycast so that one IP for an edge service routes each visitor to the nearest point of presence. Combined with caching, this is a big part of why CDN-backed sites load fast everywhere instead of only near the origin.
DDoS Mitigation
Because anycast spreads one address across many sites, attack traffic gets diluted — a flood is split across dozens of locations instead of slamming a single server. Each site absorbs only its share, which makes large volumetric attacks far easier to weather.
Common Anycast Misconceptions
Anycast is elegant, but it is easy to misunderstand what it does and does not do. Watch out for these:
Expecting Sticky Sessions
Anycast does not guarantee a client always reaches the same instance. If routing changes, a later packet may land at a different site. That is fine for stateless DNS, but for long stateful sessions you need extra care — otherwise a mid-flight reroute can break the connection. Use anycast for stateless traffic, or add session affinity at a higher layer.
Confusing It with DNS-Based Steering
Anycast works at the IP/BGP layer — routing decides the destination. DNS-based load balancing works at the name resolution layer — the DNS answer decides. They are different mechanisms (and are often combined). Assuming "nearest server" always means anycast, or always means DNS tricks, leads to wrong troubleshooting.
Thinking "Nearest" Means Geographically Closest
Anycast routes to the topologically nearest site — the best network path, fewest BGP hops — which is not always the closest on a map. Peering and routing policy can send a user to a site that is geographically farther but reachable over a better route. Plan capacity by routing reality, not by distance on a globe.
Anycast vs the Other Casts
It helps to place anycast among its siblings. Unicast is one-to-one: a packet goes to a single specific host, and it is by far the most common mode on the internet. Broadcast is one-to-all within a single subnet — every device on that local segment receives the frame. Multicast is one-to-a-group: only the hosts that have joined a multicast group receive the traffic, which is efficient for things like streaming to many subscribers. Anycast is the odd one out: one IP, many possible destinations, and the network chooses the nearest. Same packets, very different delivery semantics.
Anycast and Load Balancing Together
People often ask whether anycast is load balancing. Not exactly. Anycast spreads users across sites as a natural consequence of routing, which does distribute load — but it balances by network topology, not by server health or fine-grained policy. Real deployments usually combine anycast (to get users to the nearest site) with a load balancer inside each site (to spread requests across healthy backends there). The two layers complement each other: anycast handles the global "which city," load balancing handles the local "which server."
The bottom line: anycast is one IP advertised from many places, with the internet's routing quietly delivering each user to the nearest live copy. That single idea buys you lower latency, spread load, and automatic failover — which is exactly why it underpins DNS, CDNs, and DDoS defense across the modern internet.
Frequently asked questions about anycast
What is anycast?
Anycast is an addressing and routing technique where the same IP address is advertised over BGP from multiple physical locations at once. The internet's routing then delivers each user's packets to the topologically nearest instance, the one with the best BGP path, without the user doing anything special. It is commonly used for DNS, CDNs, and DDoS mitigation.
What is the difference between anycast and unicast?
Unicast is the normal case: one IP address maps to exactly one specific host in one location, so every user reaches that single machine. Anycast advertises the same IP from many locations at once, and routing delivers each user to the nearest instance. Unicast is one-to-one; anycast is one-to-nearest-of-many. Both differ from broadcast (one-to-all on a subnet) and multicast (one-to-a-group).
How does anycast provide failover?
Because every anycast site advertises the same IP over BGP, taking one site offline simply withdraws its route. The internet's routing then recomputes the best path and automatically sends the affected users to the next-nearest site that is still advertising the address. No DNS change or client reconfiguration is needed, which makes anycast resilient by design.
Why does DNS use anycast?
DNS is stateless request-response traffic, which is exactly what anycast suits. Anycast lets a single resolver IP be served from hundreds of physical sites worldwide, giving users low latency, spreading load, and absorbing attacks. The DNS root server letters are each anycast, and public resolvers like 8.8.8.8 and 1.1.1.1 are anycast too.
Is anycast the same as load balancing?
Not quite. Anycast works at the IP and BGP layer, steering users to the nearest site based on routing, and it is often used to balance load across sites as a side effect. Classic load balancing happens at the server or DNS level and distributes requests among backends by health or policy. They solve overlapping problems and are frequently combined rather than being the same thing.
See BGP choose the path
Anycast is just BGP picking the best route to a shared IP. Peer routers over BGP, announce one prefix from more than one place, and trace which announcement your packets reach: the shortest AS path wins, the same rule that steers anycast users to a nearby site.
Launch the routing lab →