We usually remember the name of the website, but it is difficult to remember the IP address of the website, so we need an address book to index, and the address book in the network is the DNS server
DNS servers are distributed in a tree structure with high concurrency and availability, as shown in the following figure:
DNS servers are classified into the following types based on layers
-
Root domain DNS server
The root field is called. For example, www.baidu.com, which in the configuration should be www.baidu.com. (there is a dot after this), which is usually omitted when typing in the browser
Returns the IP address of the top-level DOMAIN DNS server
-
Top-level domain DNS server – Returns the IP address of the authoritative DNS server
-
Authoritative DNS server – Returns the IP address of the responding host
For example, baidu.com is a level-1 domain, and www.baidu.com is a level-2 domain (it has a host called WWW in the domain).
DNS domain name lookup rules:
- The local DNS is queried recursively between the client and the browser
- Queries between the local DNS server and the root domain and its subdomains are iterative queries
Recursive query:
After the client enters the URL, it starts a recursive search, and the search process ends when any search is found
Search in the local browser cache (Chrome :// DNS /) → Search for the local hosts file → Search for the local DNS parser cache → Search for the local DNS server
If no forwarder is configured on the local DNS server, the forwarder is queried. If no forwarder is configured on the local DNS server, the iterative search process is as follows:
There are the following optimization points in the search process:
-
DNS has multiple levels of cache – sorted by distance from browser:
Browser cache → system cache → router cache → IPS server cache → root DNS server cache → top-level DNS server cache → Master DNS server cache
-
During the mapping between domain names and IP addresses, applications have the opportunity to perform load balancing based on domain names.