问题原文
原帖链接 · Mani Bharathy · CC BY-SA 4.0
My understanding is, if I browse to example.com, first my computer will ask the root nameservers about the .com TLD nameservers, and it will be given the IP address of the .com TLD nameservers. Once it has the .com TLD nameservers, then it asks one of those TLD servers about example.com, and it is given the (authoritative) nameservers of the example.com domain. Then my computer will query that example.com domain's authoritative nameservers for any record it wants (A, MX, etc.), and it will get the IP address. Now it can finally start to communicate to the server it wanted to talk to.
This is all fine. But my problem is, I see many nameservers belong to the domain itself. For example, google.com's name servers are ns1.google.com, ns2.google.com, etc. But it's recursive: in order to find ns1.google.com, one needs to know the google.com nameserver IP address.
I know I'm clearly missing something or misunderstood something, but I don't know what it is.
已采纳解答
原帖链接 · Maximillian Laumeister · CC BY-SA 4.0
Your understanding is correct on the whole (as a minor point of clarification, it's not your computer that will recursively resolve DNS records, it's typically your ISP.)
The "missing piece" you're looking for is the glue record, which is a DNS record specifically designed to fix that circular reference.
Glue records are DNS records created at the domain’s registrar. The record provides a complete answer when the TLD nameserver returns a reference for an authoritative nameserver for a domain. For example, the domain name “example.net” has nameservers “ns1.example.net” “ns2.example.net”. To resolve the domain name, the DNS would query in order: root, TLD nameserver, and authoritative nameserver. However, by having the authoritative nameservers inside the domain itself, these nameservers cannot be found without outside assistance. This is called a ‘circular reference’. Creating a glue record, an A record served by the TLD nameserver, avoids circular references and allows for both DNS name resolution and listing the nameservers inside the domain itself.
So to look up the A record of example.com in your case, your DNS resolver will first go to the .com nameserver, it will ask for the nameservers for example.com, and it will receive not just ns1.example.com and ns2.example.com but ALSO the IP addresses of those nameservers so that your resolver knows which IP addresses to use to make further DNS queries on that domain.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
