I’ll add that it works on a system of delegation.
So there are authoritative servers (which own a part of a domain) which can then have actual records or delegate to other authoritative servers.
So the authoritative server for “com” (yes, as in .com, com is technically a valid domain name) will delegate google.com to a DNS server (likely one owned by Google). And then Google will have DNS records for mail.google.com and so on.
So looking up mail.google.com, technically you ask com DNS for the mail.google.com. It won’t have an actual record, but will essentially say “go talk to this DNS server to get google.com records”. So your computer asks this new DNS server for mail.google.com and it might have an answer, or it might have delegated the mail.google.com somewhere else.
What your computer most likely is using, however, is a recursive DNS service. You ask it for mail.google.com and it will “walk the tree” to finally return the IP address.
And then it will cache the results (for comgoogle.com and mail.google.com) so the next queries are significantly faster.
I’ll add that it works on a system of delegation.
So there are authoritative servers (which own a part of a domain) which can then have actual records or delegate to other authoritative servers.
So the authoritative server for “com” (yes, as in
.com,comis technically a valid domain name) will delegategoogle.comto a DNS server (likely one owned by Google). And then Google will have DNS records formail.google.comand so on.So looking up
mail.google.com, technically you askcomDNS for themail.google.com. It won’t have an actual record, but will essentially say “go talk to this DNS server to getgoogle.comrecords”. So your computer asks this new DNS server formail.google.comand it might have an answer, or it might have delegated themail.google.comsomewhere else.What your computer most likely is using, however, is a recursive DNS service. You ask it for
mail.google.comand it will “walk the tree” to finally return the IP address.And then it will cache the results (for
comgoogle.comandmail.google.com) so the next queries are significantly faster.