And just for completeness, hereās a summary of what actually happens when your request a DNS resolution (assuming nobody has anything cached). Feel free to skip this if you like.
For example, letās try to resolve www.apple.com to an IPv4 address. Our host will send our DNS server (probably your ISPās server) a request for www.apple.com, requesting an A record, containing its address.
Since nothing is cached, your ISPās server has to send a request to one of the root servers. These are a pool of (currently) 13 DNS hostnames, named A through M in the root-servers.net domain, which in turn are associated with thousands of servers distributed worldwide. The IP addresses needed to access these servers is pre-configured in all DNS servers (and can be dynamically updated if they change), which is how DNS servers can bootstrap themselves into operation.
The root servers only know about where the name-servers are for all of the top-level domains (.com, .net, .mx, etc.). They know nothing else. So if I send one a query for www.apple.com, I will only get NS records. In this case, the pool of Generic Top-Level Domain (GTLD) servers which are (among other things) responsible for the .com domain:
$ dig @a.root-servers.net www.apple.com
...
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
...
(Although Iām not showing it here, the A and AAAA records for the name servers are also returned, to avoid a simple request from exploding into a data-storm of DNS requests. The ādigā utility also reports metadata about the request, which Iām also not presenting here.).
So, the next thing I need to do is send my request to one of those GTLD servers. They will not resolve the address, but they will give me NS records for the name servers responsible for the apple.com domain:
$ dig @a.gtld-servers.net www.apple.com
...
apple.com. 172800 IN NS a.ns.apple.com.
apple.com. 172800 IN NS b.ns.apple.com.
apple.com. 172800 IN NS c.ns.apple.com.
apple.com. 172800 IN NS d.ns.apple.com.
...
Now, I need to send my request to one of those name servers. And since they are authoritative, for the apple.com domain, they will resolve www.apple.com, returning (as we previously saw) a CNAME record declaring that it is an alias to www.apple.com.edgekey.net:
$ dig @a.ns.apple.com www.apple.com
...
www.apple.com. 1800 IN CNAME www.apple.com.edgekey.net.
...
Now we need to resolve www.apple.com.edgekey.net. And since nothing is cached, that means going all the way back to the root servers. Which will give us the GTLD pool again, because the GTLD servers are responsible for .net as well as .com:
$ dig @a.root-servers.net www.apple.com.edgekey.net
...
net. 172800 IN NS e.gtld-servers.net.
net. 172800 IN NS f.gtld-servers.net.
net. 172800 IN NS m.gtld-servers.net.
net. 172800 IN NS i.gtld-servers.net.
net. 172800 IN NS j.gtld-servers.net.
net. 172800 IN NS b.gtld-servers.net.
net. 172800 IN NS a.gtld-servers.net.
net. 172800 IN NS c.gtld-servers.net.
net. 172800 IN NS k.gtld-servers.net.
net. 172800 IN NS h.gtld-servers.net.
net. 172800 IN NS l.gtld-servers.net.
net. 172800 IN NS g.gtld-servers.net.
net. 172800 IN NS d.gtld-servers.net.
...
So we now send that request to a GTLD server and get the name server for edgekey.net:
$ dig @a.gtld-servers.net www.apple.com.edgekey.net
...
edgekey.net. 172800 IN NS ns1-66.akam.net.
edgekey.net. 172800 IN NS usw6.akam.net.
edgekey.net. 172800 IN NS adns1.akam.net.
edgekey.net. 172800 IN NS ns4-66.akam.net.
edgekey.net. 172800 IN NS ns7-65.akam.net.
edgekey.net. 172800 IN NS ns5-66.akam.net.
edgekey.net. 172800 IN NS a6-65.akam.net.
edgekey.net. 172800 IN NS a12-65.akam.net.
edgekey.net. 172800 IN NS a5-65.akam.net.
edgekey.net. 172800 IN NS a16-65.akam.net.
edgekey.net. 172800 IN NS a18-65.akam.net.
edgekey.net. 172800 IN NS a28-65.akam.net.
edgekey.net. 172800 IN NS a13-65.akam.net.
...
Note that all of these are various Akamai DNS servers, which is as weād expect since Edgekey is an Akamai service. So we now send our request to one of these, which tells us that (as we previously saw) it is a CNAME alias to www.apple.com.edgekey.net.globalredir.akadns.net:
$ dig @ns1-66.akam.net www.apple.com.edgekey.net
...
www.apple.com.edgekey.net. 21600 IN CNAME www.apple.com.edgekey.net.globalredir.akadns.net.
...
So now we go around again to resolve this hostname. Letās assume that weāve already cached the fact that .net is handled by the GTLD servers and send our request there first. We get a different pool of Akamai DNS server (apparently, edgekey.net is managed by a different set of servers from akadns.net):
dig @a.gtld-servers.net www.apple.com.edgekey.net.globalredir.akadns.net
...
akadns.net. 172800 IN NS a3-129.akadns.net.
akadns.net. 172800 IN NS a7-131.akadns.net.
akadns.net. 172800 IN NS a11-129.akadns.net.
akadns.net. 172800 IN NS a1-128.akadns.net.
akadns.net. 172800 IN NS a9-128.akadns.net.
akadns.net. 172800 IN NS a5-130.akagtm.org.
akadns.net. 172800 IN NS a28-129.akagtm.org.
akadns.net. 172800 IN NS a13-130.akagtm.org.
akadns.net. 172800 IN NS a18-128.akagtm.org.
akadns.net. 172800 IN NS a12-131.akagtm.org.
...
And now we send the request to one of those DNS servers to find that is is (as we already know) yet another CNAME, aliasing it to e6858.dscx.akamaiedge.net:
$ dig @a3-129.akadns.net www.apple.com.edgekey.net.globalredir.akadns.net
...
www.apple.com.edgekey.net.globalredir.akadns.net. 3600 IN CNAME e6858.dscx.akamaiedge.net.
...
So here we go again. As before, we have already cached the fact that .net is handled by the GTLD pool, but since we havenāt yet seen or cached akamaiedge.net, we need to send our request there next, and weāll get yet another pool of Akamai DNS servers for that domain:
$ dig @a.gtld-servers.net e6858.dscx.akamaiedge.net
...
akamaiedge.net. 172800 IN NS la1.akamaiedge.net.
akamaiedge.net. 172800 IN NS la3.akamaiedge.net.
akamaiedge.net. 172800 IN NS lar2.akamaiedge.net.
akamaiedge.net. 172800 IN NS ns3-194.akamaiedge.net.
akamaiedge.net. 172800 IN NS ns6-194.akamaiedge.net.
akamaiedge.net. 172800 IN NS ns7-194.akamaiedge.net.
akamaiedge.net. 172800 IN NS ns5-194.akamaiedge.net.
akamaiedge.net. 172800 IN NS a12-192.akamaiedge.net.
akamaiedge.net. 172800 IN NS a28-192.akamaiedge.net.
akamaiedge.net. 172800 IN NS a6-192.akamaiedge.net.
akamaiedge.net. 172800 IN NS a1-192.akamaiedge.net.
akamaiedge.net. 172800 IN NS a13-192.akamaiedge.net.
akamaiedge.net. 172800 IN NS a11-192.akamaiedge.net.
...
And now we send our request to one of those DNS servers. But note that weāre not getting an address yet. The akamaiedge.net DNS server doesnāt know the address for the full hostname, so it sends us more NS records for servers that are authoritative for the dscx.akamaiedge.net domain:
$ dig @la1.akamaiedge.net e6858.dscx.akamaiedge.net
...
dscx.akamaiedge.net. 4000 IN NS n3dscx.akamaiedge.net.
dscx.akamaiedge.net. 4000 IN NS n4dscx.akamaiedge.net.
dscx.akamaiedge.net. 4000 IN NS n2dscx.akamaiedge.net.
dscx.akamaiedge.net. 4000 IN NS n1dscx.akamaiedge.net.
dscx.akamaiedge.net. 4000 IN NS n7dscx.akamaiedge.net.
dscx.akamaiedge.net. 4000 IN NS n6dscx.akamaiedge.net.
dscx.akamaiedge.net. 4000 IN NS n5dscx.akamaiedge.net.
dscx.akamaiedge.net. 4000 IN NS n0dscx.akamaiedge.net.
...
So we now send our request to one of those DNS servers, which finally returns an A record, which gives us the IP address we need:
$ dig @n3dscx.akamaiedge.net e6858.dscx.akamaiedge.net
...
e6858.dscx.akamaiedge.net. 20 IN A 23.55.200.211
...
When you realize all that must go on behind the scenes, itās pretty incredible that most of the time when you type in or click on a URL, that address resolution happens so fast it seems immediate.
A lot of this is due to the fact that DNS servers cache quite a lot of data, so requests for commonly-accessed hostnames (like Appleās web server) are almost always resolved using values cached by nearby DNS servers.
But when something changes, clients may need to wait for those cached values to expire, which might take a few days. Ideally, the old IP address should remain valid for a few days during the transition period so users donāt see an interruption, but when thatās not possible (or if the transition isnāt done properly), users may see a site go off-line for a couple of days until the cached data expires, and then it will āmagicallyā come back with its new address.