Interviewer: What is the DNS protocol? Can you describe the complete DNS query process?

Interviewer: What is the DNS protocol? Can you describe the complete DNS query process?

[[400343]]

This article is reprinted from the WeChat public account "JS Daily Question", the author is Huihui. Please contact the JS Daily Question public account to reprint this article.

1. What is

DNS (Domain Names System) is an Internet service that converts domain names and their corresponding IP addresses.

Simply put, DNS is equivalent to a translator, responsible for translating domain names into IP addresses.

  • IP address: A long string of numbers that uniquely identifies a computer on a network.
  • Domain name: It is the name of a computer or computer group on the Internet, consisting of a string of names separated by dots, used to locate the computer during data transmission.

2. Domain Name

A domain name is a hierarchical structure, from top to bottom, it is the root domain name, top-level domain name, second-level domain name, third-level domain name...

For example, www.xxx.com, www is the third-level domain name, xxx is the second-level domain name, and com is the top-level domain name. The system has made compatibility for users, and the root domain name at the end of the domain name generally does not need to be entered.

There is a domain name server at each level of the domain name, as shown below:

In addition, there is the computer's default local domain name server

3. Query method

There are two ways to query DNS:

  • Recursive query: If A requests B, then B, as the recipient of the request, must give A the answer he wants.

Iterative query: If receiver B does not have the exact content that requester A needs, receiver B will tell requester A how to obtain the content, but will not make the request itself.

4. Domain name cache

When the domain name server is resolving, use the cache to save the mapping between the domain name and the IP address

The DNS records in the computer are also divided into two cache modes:

  • Browser cache: After obtaining the actual IP address of the website domain name, the browser will cache it to reduce the loss of network requests.
  • Operating system cache: The operating system cache is actually the hosts file configured by the user

5. Query process

The process of resolving a domain name is as follows:

  • First, search the browser's DNS cache, which maintains a table of domain name and IP address correspondence
  • If there is no hit, continue searching the operating system's DNS cache
  • If there is still no hit, the operating system sends the domain name to the local domain name server, which uses recursive query to query its own DNS cache and returns the result if the search is successful.
  • If the DNS cache of the local domain name server does not hit, the local domain name server will iteratively query the superior domain name server.
    • First, the local domain name server sends a request to the root domain name server, and the root domain name server returns the address of the top-level domain name server to the local server.
    • After the local domain name server obtains the address of the top-level domain name server, it initiates a request to obtain the address of the authority domain name server.
    • The local domain name server initiates a request to the authority domain name server based on its address, and finally obtains the IP address corresponding to the domain name.
  • The local domain name server returns the obtained IP address to the operating system and caches the IP address itself.
  • The operating system returns the IP address to the browser and caches the IP address itself.
  • At this point, the browser has obtained the IP address corresponding to the domain name and cached the IP address.

The process is shown in the figure below:

References

https://zh.wikipedia.org/wiki/%E5%9F%9F%E5%90%8D%E7%B3%BB%E7%BB%9F

https://www.cnblogs.com/jmilkfan-fanguiju/p/12789677.html

https://segmentfault.com/a/1190000039039275

https://vue3js.cn/interview

<<:  Free and easy to use! This data recovery software found my video from two years ago

>>:  China Mobile launches A-share listing: "Making money" but not "cutting leeks"

Recommend

Denodo announces product launch in China through AWS Marketplace

Beijing, June 8, 2021 - Denodo, a leader in data ...

5G will soon be available to ordinary people

Currently, 5G has become a hot topic in the indus...

Detailed explanation of Nginx configuration SSL (HTTPS)

As Internet security becomes increasingly importa...

5G is coming: analyzing the fronthaul solution of high-density wireless systems

The LTE era of wireless communications has been f...

Understanding Observability and Opentelemetry in one article

√Introduction to Observability √Introduce the cor...

PAM4 and Coherent Technology in 100G DWDM Optical Modules

[[385177]] 100G transmission in data centers is p...

Five ways edge computing drives digital business

Every industry has created a new normal: if your ...