The Domain Name System (DNS) is a protocol, specifically an application layer protocol based on UDP. The main purpose is to resolve a domain Name into an IP address, a process called Name resolution.
This article briefly introduces the following three DNS query methods:
- Recursive query
- Iterative query
- Non-recursive query
If we think of a DNS query as a story, a complete story needs to involve actors and events
role
Client
While the browser and operating system are ignored, client is simply abstracted to represent a requester
DNS Server
Except the Client that initiates the request, all nodes that pass through the DNS query are DNS servers
DNS Resolver
In fact, Resolver is also a DNS server, but it is special. We call the DNS server that accepts Recursive Query a Resolver. Due to performance considerations, many DNS servers accept Iterative requests only, rather than Recursive ones, and cannot become resolvers
ISP (Internet Service Provider)
Internet service providers, in China such as telecom, netcom and so on
Root Name Server
A total of 13 DNS servers in the world are responsible for returning the authoritative DNS addresses of top-level domains (.com, etc.)
Top Level Domain Name Server
Responsible for returning the authoritative DNS address for a level 1 domain such as example.com
Authoritative Name Server
Responsible for returning Address records under its domain name (A record)
The event
Recursive Query
Recursive query is a query method that occurs when a Client requests a DNS Server. When a Client sends a domain name resolution request, the DNS Server must return the corresponding IP address or an error that cannot be found.
Iterative Query (Iterative Query)
Iterative query usually occurs between DNS servers. When a Client sends a domain name resolution request, the DNS Server needs to give the best answer. The best answer may be the nearest TOP-LEVEL domain name Server or the authoritative domain name Server. In any case, the Client needs to request the returned result again until the final result is obtained.
Non-recursive Query
A non-recursive query occurs between the Client and DNS Server, meaning that the requested DNS Server already knows the answer and returns directly. In this case, the DNS Server caches the corresponding IP address locally or the authoritative Server caches the corresponding domain name. In the second case, just send the request again and get the result back.
The story
example.com
Recursive query
example.com
Recursive query
Iterative query
The root DNS server returns the IP address of the top-level domain name server (.com), the TLD returns the IP address of the authoritative domain name server (example.com), and finally sends a query request to the authoritative domain name server (example.com). That is the server address of example.com
It can be seen that DNS query requests from clients to ISP are recursive, while ISP’s query from the root DNS server is iterative. Such queries are designed to ensure performance because recursive queries are much more stressful on the server than iterative queries.
Here is a brief introduction to the role of router. Generally, WE use DHCP, and ISP will assign a DNS Server to us as a Resolver. But because we use a router, the router intercepts this DNS Server and assigns the router’s own IP as the DNS Server for our computer. The end result, as mentioned above, is that all DNS requests go through the router. We can specify the DNS server for our computer, such as Google 8.8.8.8, so that our Resolver becomes the DNS server, and does not pass through the router. Of course, it’s best to use the router, because the router does the caching for us.
Ref
- www.cloudflare.com/learning/dn…
- Dyn.com/blog/dns-wh…
- www.youtube.com/watch?v=PS0…
- www.youtube.com/watch?v=mpQ…
- Ns1.com/resources/d…