I think I figured it out so I will share it with others who might be wondering how this works.
Well, from what I understand Google owns its own DNS authoritative name servers (which means it can return whatever IP address it wants each time), so it first determines the location of your IP and then spits out a random A address (or multiple addresses) of their servers near you.
That's why every time you do a DNS lookup for www.google.com (or from different locations world-wide) you get a different A IPv4 address (or multiple addresses). That's how they balance the load, and then from there they can balance it even further. It's like a "Round Robin DNS" on steroids.
![enter image description here](../../images/3834973350.webp)
This is a little picture I put together to illustrate it. So your computer (or router) asks the Resolver DNS server what the A record for www.google.com
is and if it doesn't have it stored in cache it will contact the Root DNS server
and ask it. It will return the IP address of the .com
name server so the Resolver DNS will ask the .com name server. the .com name server will return the address of Google's name servers ns.google.com
. Then it goes and asks it. It (seeing you are from Europe/Asia/Americas) will return you the IP addresses of servers closest to you. And then the Resolver DNS server will round-robin-randomly return those records to you and your client will start by picking the first one off that list. I guess if it won't be available it will pick the next and so on.
Please feel free to correct me if I'm wrong somewhere on this.