In-depth DNS Principle

Source: Internet
Author: User
Tags subdomain name

DNS is divided into client and server. The client plays the role of question, that is, to ask the server a domain name, and the server must answer the real IP address of this domain name. The local DNS first queries its own database. If your database does not exist, you will ask the DNS set up on the DNS. After you get the answer, you will save the answer and answer the customer.

The DNS server records the name information of the domain based on the authorization zone. This information includes the subdomain name and host name under the domain.

Each name server has a cache ), the main purpose of this cache area is to record the name and IP address of the name server in the cache area, in this way, when another client goes to the server to query the same name, the server does not need to look for other hosts, you can directly find the name record from the cache and send it back to the client to speed up the client's query of the name. For example:

When the DNS Client queries a host name on the Internet from a specified DNS server, the DNS server searches for the name specified by the user in the database, the server will first query whether there is a record in its own cache. If this record is found, the server will directly return the corresponding IP address to the client from the DNS server, if the name server cannot find the data record and the cache is not, the server will first query the name of the server with another name. For example:

The DNS Client queries a host name on the Internet from the specified DNS server. When the DNS server cannot find the name specified by the user in the data record, it will switch to the cache area of the server to check whether the data exists. When the cache area cannot be found, it will ask the nearest name server for help in searching for the IP address of the name, the query results of the same action are also displayed on the other server. When the query results are found, the server that originally requested the query will be returned. After receiving the query results from the other DNS server, first, record the Host Name and corresponding IP address to the cache, and then return the query result to the client.

Example

For example, suppose we want to query the name of an InternetWww.test.com.cnFrom this name, we know that this host is located in CN, China, and the organization name test.com.cn is the WWW host under this domain. The following is each step of the name resolution process.

In step 1, enter the host query command on the DNS Client (reslover), for example:

C:/pingWww.test.com.cn

PingingWww.test.com.cn[192.72.80.36] with 32 bytes of data

Reply from 192.72.80.36 bytes time <10 ms TTL 253

In step 2, the specified DNS server first queries whether the host name belongs to the domain. If you find that the host name is not within the domain, then, the system queries the record information in the cache area to check whether the machine name exists.

After "Step 3" is queried, it finds that this record information is not found in the cache area, and a server in the root domain will be obtained.Www.test.com.cn.

In the root domain, step 4 asks the root name server about which DNS servers are responsible for each top domain, so he will respond to the nearest name server as the DNS servo host that controls the CN domain.

In step 5, the root name server has told the local DNS server which is in charge of the domain. cn, and then the local DNS sends a queryWww.test.com.cnRequest.

In step 6. in the CN domain, the specified DNS server does not find a record for this name on the local machine, so the DNS server that originally issued the query request will respond and say where the most recent server is located? He will respond to the latest host as the DNS servo host that controls the com.cn domain.

The DNS server host originally queried in Step 7 will send a search request to the DNS server of the com.cn domain after receiving the IP address location where the query continues.Www.test.com.cnName Search requirements.

In the domain name of Step 8 com.cn, the specified DNS server does not find this name on the local machine, so I will reply to the DNS server for the query request to tell him where the closest server is? He then responded to the DNS host closest to the domain that controls test.com.cn.

The DNS server originally queried in Step 9 sends a query to the DNS server of the test.com.cn domain at the location where the query should continue.Www.test.com.cnThe requirements will be found at the DNS server of the test.com.cn domainWww.test.com.cnThe IP address of the host.

Step 10 is the DNS server that originally issued the query requirements. After receiving the IP address of the query result, the server returns the response to the DNS client with the original query name.

Two real DNS query modes

There are two inquiry principles: recursive and interactive. The former is asked by the DNS proxy, the method of asking is interactive, and the latter is directly interactive inquiry by the local machine. As shown in the preceding example, the two query modes are interactive during the query name process.

Recursive (recursive): the DNS client sends a query mode to the DNS server. This mode sends a query request to the packet to be queried and waits for a correct response with the correct name, this method only processes whether the returned packet is correct or indicates that the error message with this name cannot be found.

Interactive: the query mode between DNS servers, which is sent by the client or DNS server, the information returned by the response is not necessarily the correct name location, but it is not an error message that the response is mentioned above. The response will tell you the closest IP address location, then go to the nearest IP address to find the name to be resolved, and repeat until the correct position is found.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.