TCP/IP study notes (8)-DNS domain name system

Source: Internet
Author: User

As mentioned above, accessing a machine depends on the IP address and MAC address. The MAC address can be obtained through the ARP Protocol. Therefore, this is transparent to users, but the IP address cannot be used, in any case, users need to use a specified IP address to access a computer, and the IP address is not easy to remember, so a DNS system appears.
 
1. DNS SYSTEM INTRODUCTION
The full Name of DNS is Domain Name System. It is responsible for translating the FQDN (the name ending with ".") into an IP address. The initial dnssystem uses a huge hosts.txt file (surprised, how can this be used ?), However, the development requires that the data warehouse be replaced by the hosts.txt file, and finally the distributed database is developed.
 
From the 143 page of the book, we can see that the DNS system is a huge tree with an unsung root at the top. The next layer is arpa, com, edu, gov, int, mil, us, cn. Among them, arpa is the top of the domain name anti-resolution tree, while com, edu, and other domain names are originally used only in the United States (this is the technical privilege), but now almost all over the world; us, cn, and so on are called country domains. The domain names in this tree are not centrally managed. The Network Information Center (NIS) is responsible for assigning top-level domains to authorization institutions in other designated regions.
 
An independently managed DNS subtree is called zone. The most common region is the second-level domain name, for example, .com.cn. We can also divide this second-level domain name into smaller areas, such as sina.com.cn.
 
The DNS system is a distributed database. When a database finds that it does not have the data required for a query, it forwards the query, and the forwarding destination is usually the root server, the root server forwards queries from top to bottom until the target is found. Another feature of DNS is its high-speed cache. DNS caches the queried data somewhere for use in the next query.
 
2. DNS protocol
A dns message defines a message format that can be queried or responded. For specific formats, see P145. The fields are briefly described as follows:
 
The first 16 bits uniquely identify the problem number, which is used by the query end to differentiate itself from the query.
The next 16 bits can be further subdivided to indicate the nature and details of the message, such as querying or responding to the message, whether or not recursive query is required (generally, the server supports recursive query without any settings. This is the case for BIND)
Query problems are followed by query types, including A, NS, CNAME, PTR, HINFO, and MX. If you are familiar with BIND, you will know in zong's configuration file, each record records its own type. For example, A is an IP address, and NS is A name server.
Response packets can reply to multiple IP addresses, that is, the domain name can correspond to multiple IP addresses, and there are many CNAME.
3. Reverse Query
Forward query refers to the query of the IP address obtained through the domain name, and reverse query refers to the query of the domain name obtained through the IP address. For example, if the host command is used, the host ip can get the server domain name, and the host domainName can get the IP address.
 
People who know a little about the data structure can realize that reverse queries are performed in the forward query domain. The only way to do this is to traverse the entire data set-for DNS, that is, traverse the entire database, this will bring a huge burden, so DNS adopts another method, using another subtree to maintain the corresponding table of IP-> domain name. The root node of this subtree is a in-addr.arpa, And the DNS address of an IP such as 192.168.11.2 is 2.11.168.192.in-addr. arpa (ip inversion ). In the DNS system, A reverse address corresponds to a ptr record (corresponding to A record), So reverse query is also called A pointer (PTR) query.
 
4. discussion of other issues
4.1.DNS high-speed cache
BIND9 is a high-speed cache server by default. It transfers all the queries to the root server, and then obtains the results and places them in the local buffer to speed up the query. If you are interested, install BIND9 and try it. The custom zone can specify the cache time, usually one day (1D in the configuration file ).
 
4. 2. Use UDP or TCP
The DNS server supports both TCP and UDP protocols, and the port number is 53. Most of the queries are UDP queries. Generally, TCP queries are required in two cases:
 
When the data size is so large that data truncation (TC mark 1) occurs, you need to use the TCP fragment capability for data transmission (see the relevant chapter of TCP ).
When the master Server communicates with the slave server, the slave server obtains the zone information of the master server.
End

Author's block

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.