The role and working principle of DNS

1. The role of DNS

DNS is divided into Client and Server. Client plays the role of asking questions, that is, asking Server for a Domain Name, and Server must answer the real IP address of the Domain Name. How does DNS perform name resolution?

2 DNS has three components:

2.1 Client

Client: It is the terminal used by the real user. For the terminal user, it is difficult to remember the complex IP address. Therefore, using DNS resolution, you only need to remember the simple and easy-to-use domain name. In addition, when the IP address of the application is adjusted, the client does not need to know the new IP address, but only needs to access the unified domain name.

2.2Local DNS

Local DNS: Local DNS is usually the DNS server address pre-configured on the client, or the
DNS server address assigned by the DHCP protocol when the user uses ADSL and other network services.
Local DNS provides DNS resolution service directly to clients .

2.3 Authoritative domain DNS server

Authoritative domain DNS server: The corresponding relationship between the domain name and IP address configured on the authoritative domain DNS server is provided to LocalDNS or the client for direct query. When the IP address of the application is adjusted, you only need to change the correspondence between the domain name and the IP address on the authoritative domain DNS server, and all clients or Local DNS queries will get new corresponding records. The DNS server will record each name information under the domain according to different authorized zones (Zone). This information includes the sub-domain name and host name under the domain.

3 working process

There is a cache cache in each Local DNS server. The main purpose of this cache cache is to record the name and relative IP address queried by the Local DNS server in the cache cache. In this way, when another client goes to the Local DNS server to query the same name next time, the server does not need to go to the authoritative domain name server to find it, but can directly find the name record from the cache and send it back to the client. Accelerates the speed of client queries for names. For example: when the DNS client queries the specified Local DNS server for a host name on the Internet, the Local DNS server will look for the name specified by the user in the cache. If the name record is found, it will directly match the name to the The record corresponding to the domain name and IP address of the domain name and IP address is sent back to the client. If the Local DNS server cannot find the corresponding record in the local cache, it will query the desired name from the authoritative domain name server.

Figure: How DNS works

Let's take an example, assuming we want to query a name on the Internet called www.adntech.com, the following is
each step of the name resolution process.

  1. Enter http://www.adntech.com in the address bar of the DNS client browser, then the local DNS
    client in the client browser first initiates www.adntech to the configured or assigned DNS server. com's domain name resolution request, the DNS server configured by the client here is usually called the Local DNS server.
  2. The Local DNS server first inquires whether there is a valid
    DNS record of www.adntech.com in the local cache, and if it finds that there is a corresponding DNS record within the validity period, it will directly return the result of Local DNS resolution.

  3. After querying, if it is found that there is no such record in the local cache, it will directly initiate a request to a certain root DNS server from the root DNS server IP address list pre-configured on this machine, and query www.adntech.com.

  4. In the root DNS server, it is recorded which DNS server is responsible for each top-level domain, so it will return the authoritative DNS server record of the .com domain to the Local DNS server that initiated the request.

  5. Local DNS then initiates a domain name resolution request for www.adntech.com to the authoritative DNS server of .com, and the authoritative DNS server of .com returns the IP address corresponding to the authoritative domain name server record of adntech.com to Local DNS.
  6. Local DNS then initiates a domain name resolution request for www.adntech.com to the authoritative domain name server of adntech.com. At this time,
    the authoritative domain name server of adntech.com returns the IP address corresponding to the www.adntech.com domain name to Local DNS.
  7. The client's local DNS client will return the analysis result to the browser, then the browser will initiate an HTTP GET command to port 80 of the IP address corresponding to www.adntech.com, and the web server will return the corresponding request content

Each domain name resolution record has a corresponding TTL value. According to the time defined by this TTL value, both the client and LocalDNS will cache the resolved results locally until the TTL value arrives, and then initiate a new DNS query request. For the client, within the valid time of the TTL, if the browser or other applications on the machine need to access this domain name, there is no need to perform a query action, but directly obtain the resolution result from the local cache and then connect to the corresponding IP address. For Local DNS, within the effective time of TTL, any client request will directly return the record in the local cache. After the cache time expires, the previous actions will be repeated to resolve the IP address corresponding to the domain name.

Guess you like

Origin blog.csdn.net/qq_46645840/article/details/129328514