DNS (English: Domain Name System, abbreviation: DNS), generally speaking, DNS servers are divided into: DNS authoritative server and DNS cache server. The DNS authoritative server adopts an iterative query method, while the DNS cache server is generally a recursive server, which is responsible for fully processing the client’s DNS query request until the final result is returned.
The DNS authoritative server is what we call the DNS resolution server, which is provided by almost all domain name registrars.
The DNS cache server generally includes the ISP service provider DNS server or some public DNS servers, such as 114 DNS (188.8.131.52,), Baidu public DNS (184.108.40.206) and so on.
Domain name resolution record type
In the DNS system, common resource record types are:
- Host record (A record) : A record is an important record for name resolution, which maps a specific host name to the IP address of the corresponding host.
- Alias record (CNAME record) : CNAME record is used to point an alias to an A record, so that there is no need to create a new A record for a new name.
- IPv6 host record (AAAA record) : Corresponds to A record and is used to map a specific hostname to a host’s IPv6 address.
- Service location record (SRV record) : Used to define the location of the server that provides a specific service, such as host (hostname), port (port number), etc.
- Domain name server record (NS record) : used to specify which DNS server the domain name is resolved by. When registering a domain name, there is always a default DNS server. Each registered domain name is resolved by a DNS domain name server. The NS record address of the DNS server generally appears in the following forms: ns1.domain.com, ns2.domain. com etc. Simply put, the NS record specifies which DNS server resolves the domain name.
- NAPTR record: It provides a regular expression way to map a domain name. A well-known application of NAPTR records is for ENUM queries.
Technical Realization of Domain Name Resolution
DNS implements a hierarchical namespace by allowing a name server to “delegate” a portion of its name service (known as a zone) to subservers. In addition, DNS provides additional information such as system aliases, contact information, and which host is acting as the mail hub for a system group or domain.
Any computer network using IP can use DNS to implement its own private name system. Nonetheless, the term “domain name” is most commonly used when referring to domain names implemented on the public Internet DNS system.
This is based on 984 worldwide “root name servers” (divided into 13 groups, numbered A to M). Starting with these 984 root servers, the rest of the Internet DNS namespace is delegated to other DNS servers that serve specific parts of the DNS namespace.
For example, www.php.net as a domain name corresponds to the IP address 220.127.116.11 . DNS is like an automatic phone directory, we can directly dial the name www.php.net of 18.104.22.168 instead of the phone number (IP address). After we directly call the name of the website, DNS will convert a human-friendly name like www.php.net into a machine-friendly IP address like 22.214.171.124 .
Take the query www.php.net as an example:
- The client sends the query message “query www.php.net” to the DNS cache server. The DNS server first checks its own cache and returns the result directly if there is a record.
- If the record is old or does not exist, then:
- The DNS server sends a query message “query www.php.net” to the root domain name server, and the root domain name server returns the authoritative domain name server address of the top-level domain .net.
- The DNS server sends a query message “query www.php.net” to the authoritative domain name server of the .net domain, and obtains the address of the authoritative domain name server of the second-level domain .php.net.
- The DNS server sends the query message “query www.php.net” to the authoritative domain name server of the .php.net domain, obtains the A record of the host www, stores it in its own cache, and returns it to the client.
In the above example, a key value is the cache time (TTL). When doing domain name resolution settings, each record will have a TTL value. Generally, the default setting is 10 minutes (600 seconds), which is the cache time of the record. Once the cache expires or the cache does not exist, the above will be repeated. 1, 2, 3 steps.
That is to say, if the TTL value is set too small, the root name server and authoritative name server will be frequently queried. If the TTL value is set to a larger value, the result will be directly returned in the DNS cache server in most cases, which will speed up the speed of domain name resolution . However, if the TTL value is set to a large value, there will be the disadvantage that the modification and parsing records will take effect slowly.
The size of the TTL value and the performance of the DNS resolution server of the domain name will affect the normal resolution of the domain name or user experience.
Smart DNS resolution
Generally, if you need to use smart DNS resolution, it is a way to judge the resolution value according to different lines or regions when the CDN is enabled or the server has multiple mirrors. Smart DNS is a DNS solution launched for the problem of poor communication between telecommunications and China Netcom. , Great Wall Broadband) etc.
Specifically, it is to set the same domain name record to point to different values (IP), and determine which value (IP) of the domain name record should be returned according to the specified conditions of the client.