How Google Serves the Whole World From One IP Address
By Devang Pandya · Cloud Tech by Devang · Cloud • DevOps • AI — Made Simple
Type 8.8.8.8 into your network settings, and you are using Google Public DNS. Someone in Mumbai uses the same address. So does someone in São Paulo, in Frankfurt and in Sydney. One IP address, used by the whole world.
Yet these people are not all talking to one server in one building. Each of them is answered by a Google location near them. How can one IP address live in many places at once?
The answer is anycast. In this post I will explain anycast in simple English, how internet routing (BGP) makes it work, what happens when a location fails, and how it compares with DNS-based global load balancing like AWS Route 53 latency and geolocation routing. At the end you get an interview answer for: "How would you route users to the nearest region?" I have spent 14+ years in cloud, DevOps and SRE, and multi-region routing is where many teams make expensive mistakes, so this one is worth knowing well.
1. Unicast: the normal way
Most of the internet uses unicast: one IP address belongs to one machine (or one network endpoint). If you send a packet to that address, it goes to that one place, wherever it is in the world.
That is simple, but it has problems for global services:
- Users far away get high latency, because every packet travels the long way.
- One location takes all the traffic, including attack traffic.
- If that location goes down, the address goes down with it.
2. Anycast: one address, many locations
With anycast, the same IP address is announced from many locations at the same time. Each location says to the internet: "I can deliver traffic for 8.8.8.8."
Google's Public DNS FAQ explains it directly: anycast routing sends your queries to the closest Google Public DNS server. The locations announcing these anycast addresses (8.8.8.8, 8.8.4.4 and the IPv6 addresses) include nearly all of the Core data centres and Edge Points of Presence in the Google Edge Network. Google also notes that the exact set of locations changes with network conditions and traffic load.
So when you send a DNS query to 8.8.8.8, it doesn't travel to one global server. It goes to a nearby Google site.
Cloudflare's learning centre describes anycast the same way: requests to a single IP address can be routed to many different locations, typically the nearest data centre that can handle them.
3. How the internet picks "nearest": BGP
The internet is made of thousands of networks (ISPs, cloud providers, universities, companies). Each one is called an autonomous system. They tell each other which IP addresses they can reach using a routing protocol called BGP (Border Gateway Protocol).
When many Google locations announce the same address range, your ISP's routers hear several routes to it. Each router picks its best route, usually the shortest or most preferred path through the networks. Your packets follow that path to whichever Google location is at the end of it.
Two important details:
- "Nearest" means network-nearest, not map-nearest. BGP chooses by routing policy and path, not by kilometres. Usually the result is geographically close, but not always. Someone in Pune might be served from Mumbai on one ISP and from a different site on another ISP.
- Each packet makes its own choice. For short exchanges like a DNS query (one small question, one small answer), this works perfectly. For long connections, operators must make sure routes are stable so a connection doesn't "flap" between sites in the middle. Cloudflare notes that building a true anycast network needs your own network hardware, direct relationships with carriers, and careful route tuning to avoid exactly this.
4. What happens when a location fails?
This is one of anycast's best features.
If one anycast location goes down, or is taken out for maintenance, it stops announcing the route. Routers around the internet notice that path is gone and pick the next best route, to another location still announcing the same IP. Traffic shifts automatically. Users keep using the same IP address. They never change any setting.
Cloudflare puts it simply: because traffic finds the best path, an entire data centre can be taken offline and traffic will flow to a nearby data centre.
Anycast also helps against DDoS attacks. Attack traffic from bots all over the world is spread across many locations, instead of hitting one site, so each location only has to absorb its share.
Lesson for us: anycast gives you failover and attack spreading at the network layer, with no client-side changes and no DNS TTLs to wait for.
5. Who uses anycast?
- Public DNS resolvers: Google (
8.8.8.8), Cloudflare (1.1.1.1), Quad9 (9.9.9.9). - DNS root servers: many root server letters are run as anycast clouds with many instances worldwide.
- CDNs and edge networks: many CDNs use anycast to bring users to the nearest edge.
- Cloud global front doors: for example, AWS Global Accelerator gives you static IP addresses. Users enter the AWS global network at a nearby Global Accelerator edge location, and you get fast failover across Regions without depending on DNS caches. Google Cloud's global external load balancers also give one IP address for users worldwide.
You usually don't build anycast yourself. You rent it from a cloud provider or CDN.
6. The other way: DNS-based global load balancing
Not every system uses anycast. The other common way to send users to a nearby region is DNS-based routing, sometimes called GSLB (global server load balancing) or GeoDNS.
The idea: your service has different IP addresses in different regions (for example a load balancer in Mumbai and one in Virginia). When a user's resolver asks for app.example.com, the DNS service chooses which answer to give based on where the user is, which region is fastest, or which region is healthy.
Route 53 routing policies
AWS Route 53 offers several routing policies. The ones that matter most for global routing are:
- Latency routing: for resources in multiple AWS Regions. It routes users to the Region that gives the best latency.
- Geolocation routing: routes by where the user is (continent, country, or US state). This is useful for data residency or language-specific content.
- Geoproximity routing: routes by the location of your resources, and can shift traffic between locations using a bias.
- Failover routing: active-passive setup. Traffic goes to the primary, and to the secondary if health checks say the primary is down.
- Weighted routing: split traffic by percentages (for example a 10% canary in a new region).
- Also simple, multivalue answer (up to eight healthy records at random), and IP-based routing.
Anycast vs DNS routing
| Anycast | DNS-based routing (GeoDNS / Route 53) | |
|---|---|---|
| What changes per user | The network path to the same IP | The IP address returned by DNS |
| Who decides | BGP routers on the internet | Your DNS service |
| Failover speed | Fast (routing reconverges) | Depends on DNS TTL and client caching |
| Control | Less fine-grained (network decides) | Very fine-grained (latency, geo, weights, health) |
| Effort | Needs a big network, so usually rented | Easy to set up yourself |
| Typical use | DNS resolvers, CDNs, global LB front doors | Choosing a region for your own app |
In practice, many large systems use both: an anycast front door (a CDN or global load balancer) for the first hop, and DNS or load balancer rules to pick the right backend region.
Watch out for DNS caching. When Route 53 changes an answer during a failover, clients and resolvers that cached the old answer keep using it until the TTL expires. Use short TTLs for records you might fail over, and health checks so Route 53 stops returning unhealthy endpoints.
7. The example visuals
The city names in the Reel (Mumbai, Frankfurt, Iowa, Sydney, Singapore) and "You in Pune" are examples to explain the idea. They are not a list of the exact sites that answer 8.8.8.8. Google says the set of locations changes with network conditions and load, and publishes location data in its Public DNS FAQ. "ap-south-1" is shown as an example AWS region (Mumbai).
8. Try it yourself
You can see which Google Public DNS location answers you:
dig +short TXT o-o.myaddr.l.google.com @8.8.8.8
This returns an IP address that identifies the Google site handling your query. (Google's FAQ explains how to map these to locations.) Try it from your laptop, then from a cloud VM in another region. Same 8.8.8.8, different site.
9. How to answer this in an interview
Question: "How would you route users to the nearest region?"
Strong answer:
"There are two main tools. The first is anycast: the same IP is announced from many locations, and BGP sends each user to the network-nearest one. If a location fails it stops announcing, and traffic moves to the next closest automatically. Google Public DNS on 8.8.8.8 works this way, and on AWS you get a similar single-IP front door with Global Accelerator, or with a CDN. The second is DNS-based routing: Route 53 latency routing sends users to the region with the lowest latency, geolocation routes by user location, and failover routing with health checks moves traffic to a backup region. DNS gives more control, but failover depends on TTLs. So: anycast for one global IP and fast network-level failover, DNS routing to pick a region."
Follow-ups to expect:
- Why is anycast great for DNS? DNS queries are short, usually one small UDP request and response, so a route change between packets doesn't break anything.
- What's the risk with anycast for long TCP connections? Route changes can move a connection to a different site mid-stream. Providers manage this with stable routing and connection handling at the edge.
- How do you fail over a whole region? Health checks plus Route 53 failover (or Global Accelerator endpoint weights), short TTLs, and enough spare capacity in the other region.
- Latency vs geolocation routing? Latency picks the fastest region. Geolocation picks by user location, which is useful for compliance or local content.
Sources
- Google Public DNS FAQ (anycast routing to the closest server; locations include nearly all Core data centres and Edge PoPs and change with network conditions and load; o-o.myaddr lookup): https://developers.google.com/speed/public-dns/faq
- Cloudflare Learning Center, "What is Anycast? How does Anycast work?" (nearest data centre; a data centre can go offline and traffic flows to a nearby one; DDoS spreading; route tuning to avoid flapping): https://www.cloudflare.com/learning/cdn/glossary/anycast-network/
- AWS, "Choosing a routing policy" (Route 53: simple, failover, geolocation, geoproximity, latency, IP-based, multivalue answer, weighted): https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html
- AWS Global Accelerator (static IPs, onboarding at edge locations, fast multi-Region failover independent of DNS): https://aws.amazon.com/global-accelerator/
Preparing for a Cloud, DevOps or SRE interview? Book a Free 15-min Cloud & DevOps Interview Guidance Call with me: what to study, how to answer system-design and on-call questions, plus a CV and roadmap check 👉 topmate.io/cloudtechbydevang
About the author
- I help engineers learn cloud, DevOps, SRE and AI in simple English, crack interviews and follow clear roadmaps. 14+ years building and running platforms on AWS, GCP, Kubernetes and Terraform. One topic a day.
Comments
Join the discussionNo comments yet. Be the first to comment.
