What is Anycast? One IP, Many Servers

Anycast is a network addressing method where the same IP address is announced from multiple locations simultaneously. When a client sends traffic to an anycast address, BGP routing delivers it to the nearest announcing location — "nearest" in terms of network topology, not geography, though the two often correlate.

How Anycast Works

In normal unicast routing, each IP address belongs to exactly one server at one location. In anycast, the same prefix is announced via BGP from many different locations simultaneously. Each BGP router in the world sees multiple valid paths to that prefix — one for each announcing site — and selects the best one based on standard BGP decision criteria: shortest AS path, lowest MED, local preference, and so on.

For example, 1.1.1.1 is announced by Cloudflare (AS13335) from over 300 cities worldwide. When you query 1.1.1.1, your traffic goes to whichever Cloudflare data center BGP determines is topologically closest to your network. Users in Tokyo reach a server in Tokyo; users in London reach a server in London — all using the same IP address, with no client configuration needed.

Anycast: Same IP, Nearest Server Wins 1.1.1.1 (anycast) Edge: Frankfurt Edge: New York Edge: Singapore BGP announces 1.1.1.1 from each site User: Berlin User: Chicago User: Jakarta routes to nearest routes to nearest routes to nearest

Anycast vs. Unicast, Multicast, and Broadcast

IP supports four addressing models, and anycast is the most sophisticated:

ModeDestinationExample use
UnicastOne specific hostLoading a web page from a single server
BroadcastAll hosts on a subnetARP requests (IPv4 only)
MulticastA subscribed groupVideo streaming, OSPF, BGP updates
AnycastNearest of a groupDNS, CDN edge, DDoS mitigation

Where Anycast Is Used

Anycast and TCP

Anycast works naturally with stateless protocols like DNS (UDP) where each query-response pair is independent. For TCP-based services like HTTPS, anycast requires more care. A TCP connection involves a sustained exchange of packets, and all of them must reach the same physical server. If BGP re-converges mid-session — rerouting your packets to a different anycast site — the TCP connection breaks because the new server has no record of the session.

In practice, BGP routes are stable for minutes to hours, so short-lived HTTPS connections almost never experience mid-session rerouting. Longer-lived connections (WebSocket, streaming) are more vulnerable. Operators mitigate this by:

Anycast Routing Mechanics

To deploy anycast, the same prefix — say 1.1.1.0/24 — is announced via eBGP from multiple autonomous systems or from the same AS at multiple IXP peering points. Each BGP peer sees the announcement from its closest location and selects it as the best path.

Because each site announces the same prefix with the same AS path length (in the simplest case), the only differentiator is which paths BGP routes through — determined by peering topology and local preferences. Networks that are well-peered at many IXPs, like Cloudflare, achieve genuinely global anycast with fine-grained geographic distribution.

BGP Sees Multiple Equal Paths to 1.1.1.0/24 ISP Router (AS64500) 1.1.1.0/24 via AS13335 Frankfurt 1.1.1.0/24 via AS13335 Ashburn 1.1.1.0/24 via AS13335 Tokyo BGP receives all three; best path selected by AS-path / MED Best path selected: shortest AS path to nearest site wins

Anycast Failure Modes

Anycast is resilient but not immune to problems. If one site withdraws its BGP announcement — because of a fiber cut, a router failure, or a deliberate maintenance action — traffic from nearby clients is automatically rerouted to the next-closest site. This failover happens at BGP convergence speed, typically within a few seconds to a minute.

More subtly, anycast can cause asymmetric routing: a client's request might reach one site while the response travels back via a different path, which can confuse stateful firewalls or intrusion detection systems that expect to see both directions of a flow.

Viewing Anycast in the Routing Table

You can observe anycast in action using this looking glass. Anycast addresses often show routes with the same origin AS arriving via multiple different upstream paths — each representing a different physical site. Look up any major anycast address to see the convergence of AS paths:

See BGP routing data in real time

Open Looking Glass
← Previous What are TLDs? Top-Level Domains Explained
More Articles
What is DNS? The Internet's Phone Book
What is an IP Address?
IPv4 vs IPv6: What's the Difference?
What is a Network Prefix (CIDR)?
How Does Traceroute Work?
What is a CDN? Content Delivery Networks Explained