Free — no signup required

How It Works: BGP Trickery

2 min read

Announcing the Same Route Everywhere

Anycast is not a special protocol — it is a clever use of BGP (Border Gateway Protocol), the routing protocol that governs how traffic flows between autonomous networks (ISPs, cloud providers, enterprises) on the internet.

To understand the mechanism, start with how BGP normally works. Every network on the internet is an Autonomous System (AS) — a collection of IP ranges under a single administrative authority, identified by an AS Number (ASN). BGP is how ASes tell each other: "I can reach these IP ranges." When you own an IP block, you announce it to your upstream providers, who propagate that announcement globally.

In a unicast setup, only one AS announces a given IP prefix. In an Anycast setup, multiple ASes in different geographic locations announce the exact same prefix:

# New York router announces to its upstream ISPs:
203.0.113.0/24  via  AS64501 (New York)

# Frankfurt router announces to its upstream ISPs:
203.0.113.0/24  via  AS64502 (Frankfurt)

# Singapore router announces to its upstream ISPs:
203.0.113.0/24  via  AS64503 (Singapore)

Every ISP on the internet now sees three different BGP paths to 203.0.113.0/24. BGP's path selection algorithm evaluates these paths using several criteria — AS path length, local preference, MED (Multi-Exit Discriminator), and others. In practice, the dominant factor for geographically distributed Anycast is AS path length: an ISP in Germany will see the Frankfurt path as having fewer intermediate hops than the New York or Singapore paths, so it selects Frankfurt. An ISP in Japan will prefer Singapore.

The result: traffic is automatically steered toward the nearest announcement point, without any client-side configuration, DNS tricks, or application-layer logic. The routing decision happens at the IP layer, invisibly, on every packet.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free