For example, lets say there is a hosting company, hostingcompany.com, with nameserver ns1.hostingcompany.com. When I type hostingcompany.com into my browser, my computer contacts a top level .com domain nameserver, which in turn contacts the name server for hostingcompany.com to get the A record for hostingcompany.com or any of its subdomains. Isn't this circular, since the FQDN for the nameserver is a subdomain of the domain name itself? In other words, in order to find the IP address of ns1.hostingcompany.com, we need a nameserver for *.hostingcompany.com, which is itself? What am I missing?
The title of your question is asking a different question than the one in the question body.
Why does this not create circular dependencies?
Shane covered the topic of glue records. For further information, refer to What is a glue record?.
Why are NS records defined within zone files (if glue records are preferred)?
This gets somewhat complicated. There is a DNS term called bailiwick that refers to whether a DNS record is "within the authority" of a higher level label, or record.
ns1.example.com.is within the bailiwick of
ns1.contoso.com.is not within the bailiwick of
contoso.com.are both within the bailiwick of
com.is within the bailiwick of
Broken down like this, it becomes easier to explain: glue is needed for referrals to nameservers inside of bailiwick.
sub.example.org. (not in the examples above) specifies a nameserver of
ns1.contoso.com., it is not necessary to supply glue. If it were to do so, this would called "out of bailiwick glue" which is actually considered to be bad:
- The IP address of
ns1.contoso.com.would have to be managed on two different nameservers.
ns1.contoso.com.may be owned by a completely separate company.
- The operators of
ns1.contoso.com.are probably aware of the fact that they host
sub.example.org., but they have no way of knowing whether the nameservers for
example.org.are providing out of bailiwick glue for their nameserver. If they change the IP address of
ns1.contoso.com., this will completely break
sub.example.net.until the owners of
example.net.notice this and either correct the glue, or remove it.
The name can be resolved because there are glue records present in the name server for the TLD,
.com in this case.
The answer providing the name servers for
hostingcompany.com also includes the
A records that the TLD servers have for the name servers, so the resolving system (usually a recursive name server your computer's querying, not your computer itself) knows where to look.