# Anycast

> One IP address announced from many places, so each user reaches the nearest one.

- Level: Advanced
- Topics: Networks
- URL: https://tidbit.legios.com.ar/anycast/
- In Spanish: [Anycast](https://tidbit.legios.com.ar/es/anycast/)

Normally an IP address belongs to one machine in one place (**unicast**). With **anycast**, the same address is announced from many locations at once: São Paulo, Madrid, Tokyo, dozens more. Each of those sites tells its neighbors through BGP "I can deliver to 1.1.1.1", and every router on the internet simply picks the best route it knows. The result is that a user in Buenos Aires lands on the São Paulo servers and a user in Lisbon on the Madrid ones, without either of them doing anything special.

This is how the DNS root servers survive: the 13 root "letters" are served from well over a thousand anycast sites worldwide. Public resolvers like Cloudflare's 1.1.1.1 and Google's 8.8.8.8 work the same way, and so do many CDN networks. Anycast also spreads a DDoS attack across every location instead of concentrating it on one, so each site absorbs only its local share; and if a site goes down, it stops announcing the route and traffic flows to the next closest one within seconds or minutes.

The catches come from the fact that BGP picks routes by policy and path length, not by real distance or load. A user can be sent to a farther site because of how their provider peers, and route changes in the middle of a session can move a client to a different location. That is harmless for short exchanges like DNS over UDP, but long TCP connections may break if they switch servers mid-way, so operators keep state minimal, share it between sites or use anycast only to pick an entry point and then hand off.

## An analogy

A taxi company with one phone number across the whole country. You always dial the same number, and the call is answered by the dispatch office nearest to you, which sends you a nearby car. If one office closes, the next one picks up.

## Keep in mind

- Many servers share one IP address; routing sends each user to the closest by network path.
- Built on BGP: each site announces the same prefix to its neighbors.
- Used by DNS root servers, public resolvers like 1.1.1.1 and CDNs; spreads DDoS traffic.
- Best for short, stateless exchanges; long TCP sessions can break if routes shift.

## Go deeper

- [Anycast on Wikipedia](https://en.wikipedia.org/wiki/Anycast)
- [RFC 4786, Operation of Anycast Services](https://www.rfc-editor.org/rfc/rfc4786)
- [What is Anycast? (Cloudflare Learning)](https://www.cloudflare.com/learning/cdn/glossary/anycast-network/)

## Related terms

- [IP address](https://tidbit.legios.com.ar/ip-address/): The number that identifies a device on a network, like a postal address.
- [BGP](https://tidbit.legios.com.ar/bgp/): The protocol networks use to tell each other which addresses they can reach.
- [Router](https://tidbit.legios.com.ar/router/): The box that connects your devices to each other and to the internet.
- [Internet](https://tidbit.legios.com.ar/internet/): A worldwide network of networks that lets any connected device reach any other.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [DNS](https://tidbit.legios.com.ar/dns/): The internet's phone book: it turns names like wikipedia.org into IP addresses.
- [Cloudflare](https://tidbit.legios.com.ar/cloudflare/): A global network that sits in front of websites to make them faster and safer.
- [Google](https://tidbit.legios.com.ar/google/): The search company that gives most products away and makes its money on ads.
