http-DNS domain name resolution process understanding

Regarding the specific process of how to browse the web through URL, this kind of question is always vague in the DNS part, so detailed inquiries and understanding have been carried out for this one.

What is DNS

  • Domain Name System
  • DNS is short for Domain Name System
  • It is a hierarchical structure and distributed database
  • The function is: complete the mapping of domain name-ip address
  • DNS is based on udp
  • The cache has an expiration time

Give the DNS server a domain name, for example, www.baidu.com, and it will return you an IP address.
The reason why DNS is distributed here is because there are many requests and high pressure, so it needs to be distributed.
The layering is because there are too many domain names and it is difficult to manage a group of nodes. Therefore, the domain names are divided by a single label dividing point, so that only part of each layer is managed.

The name hierarchy of the DNS domain is as follows: It
Insert picture description here
can be seen that it is a tree-like structure, (when each split point is regarded as a character, it is a bit like a prefix tree)
For this tree, we need to proceed from the root node every time Visit, traverse down, and query

Different levels also have different names (domain name space)
Insert picture description here
. For example, www.qq.com actually has a dot at the end, representing the root domain. In the browser, the default top-level domain name is generally omitted to
represent different organization types.
Insert picture description here

DNS resolution process

When we type url in the address bar of the browser. Such as www.csdn.net.
Will carry out the following sequence of operations

  1. Check the cache in the browser first, if there is an ip address of the domain name, return directly without proceeding to the next step
  2. Check the hosts file of the system to see if there is an ip address of the domain name in it. If there is a direct return, there is no next step (because this step is more dangerous, the hosts file is generally set to read-only, if you want to modify it, it is recommended to modify the permissions, then It would be better to use switchhost model management)
  3. Find the dns server set together with your ipv4 address mask, that is, the local domain name server, if there is one, then return, if there is no next step. ( From this step, all the interactive power is handed over to the local domain name server, which will execute it on its behalf )
  4. The local domain name server accesses the root domain name server (in fact, it is to visit the tree above), and the root domain name server tells the local domain name server, who is authorized to manage the domain name .net, and you find it yourself.
  5. So the local domain name server visits the top and bottom domain name servers of .net, and then .net tells the local domain name server that this is managed by my subordinate .csdn.net, you go find it
  6. If so, the host www.csdn.net is finally found, and the local domain name server caches this information and returns it to the user
  7. The user caches the information, and accesses the corresponding ip address, so that the resolution is changed to

From this, we can understand the whole process. The core here is the interaction between the local domain name server and many domain name servers.

The example in the following figure is different, but it is also easy to understand
Insert picture description here

Reference

https://blog.51cto.com/369369/812889
https://blog.csdn.net/qq_38218238/article/details/82425974
https://www.cnblogs.com/crazylqy/p/7110357.html

Guess you like

Origin blog.csdn.net/qq_34687559/article/details/114116793