DNS:domain name server

  • Introduction to the Domain Name System;
  • Similarities and differences between the two queries
  • Data Format;
1. Overview of the Domain Name System

The domain name system is to convert the domain name that is easy and human memory into a 32-bit IP address that is easy for machines to process;

Domain names are named in a hierarchical tree structure, and the domain name system DNS is an online distributed system. The disadvantages of a single-electric system are:

  1. A single point of failure leads to the paralysis of the network system;
  2. large flow;
  3. The geographical distribution is uneven, resulting in a large RTT time for requests far away from the dns server;

==In order to reduce the overhead, the transport layer uses the UDP protocol==

1.1 The Domain Name Structure of the Internet

The domain name structure of the Internet is a tree-loaded hierarchical structure. This naming method == can make hosts or routers on the Internet have a unique hierarchical name, that is, domain name ==.

For example www.cctv.com, the part between the punctuation marks is called a label, == each label does not exceed 63 characters, the total length of the domain name does not exceed 255 characters, the number of subordinate domain names is not limited, and the domain names at all levels are directly managed by the superior domain name = =, not subject to the restriction of higher-level institutions.

The domain name is only a logical concept, not the physical location of the computer;

Top level domain (TLD: top level domain) is divided into 3 parts:

  1. The top-level domain name representing the country, such as cn;
  2. Generic top-level domain names, such as com companies, net network service organizations, org non-profit organizations, int international organizations, edu US educational institutions (edu.cn in China), gov government departments (similar to the cn suffix in China), mil US military branch;
  3. Infrastructure domain name: there is only one arpa, which is used for reverse domain name resolution;

An example of a domain name tree is as follows:

  1. For example mail.cctv.com, com is the top-level domain name, and then cctv and mail are the second-level domain name and the third-level domain name respectively, which are only related to them and have nothing to do with the naming, see "mail" in the figure above;
  2. ==The leaf of the domain name tree is the name of a single computer, and subdomains cannot be further divided==.
1.2 Domain Name Server

The scope that each domain name server is responsible for is called a zone. This domain name server is called an authoritative name server . A zone is a subset of a domain. Examples are as follows:

Domain name servers are roughly divided into 4 totals, namely root domain name server root name server, top-level domain name server TLD server, authority domain name server and local domain name server local name server. The specific meanings are as follows:

  1. There are 13 root domain name servers, corresponding to 13 ip addresses, but not only 13 machines, but 13 installations, one in Beijing, one in Taipei and one in Hong Kong;
    1. As above, there are multiple root domain name server nodes. In order to speed up the resolution, the root domain name server adopts anycast technology so that routers on the Internet can find the root domain name server closest to the requesting client;
    2. When the local domain name cannot resolve the resolution request sent by the client, == will first resort to the root server ==;
  2. TLD server: responsible for managing all second-level domain names under the top-level domain name. The response to the request may be the result, or it may be to inform the user which server to query;
  3. Authority domain name server: as above, responsible for the domain name server of a zone;
  4. The local domain name server is not in the diagram, but organizations such as universities, companies, etc. can have their own one or polymorphic local domain name servers, also known as "default domain name servers". ==The local domain name server is the first stop for client requests==;

In order to ensure service reliability, the NDS server also uses master-slave replication, only the master server can write, and periodically updates data to other servers to ensure consistency.

==The domain name resolution process is generally divided into recursive query and iterative query ==. The schematic diagram is as follows:

  • Iterative query: The root server tells the local server which top-level domain name server to query, and the TLD server tells the LDS which server to query;
  • Recursive query: When the domain name server at this level does not know the result, it sends a query request to the next domain name server instead of the requesting end, and the result is returned layer by layer in the same way;

In order to improve efficiency, reduce the load on root domain names and reduce the number of DNS query packets on the Internet, caching is widely used in == domain name servers. In order to ensure that the data in the cache is correct, the server should set the validity period == for each item of data.

3. Message logging and message format

The format of the DNS record (RR: resource record) is as follows:

RR format(name,value,type,ttl),ttl refers to the validity period of this record (time to live), name and value have different meanings in different types, as shown below:

  1. type=A: name is the host domain name, value is the IP address;
  2. type=NS: name is the domain (edu.cn), and value is the domain name of the host server responsible for resolving the domain;
  3. type=CNAME: name is the alias of the official domain name, value is the real domain name, such as www.baidu.com and www.a.shifen.com;
  4. type=MX: value is the corresponding mail server;
DNS message format

The DNS message format and its occupancy are shown in the following figure:

  • 16-bit ID: the request and its corresponding ID are the same;
  • QR tag, which identifies the actual request or response;
  • Opcode: 4-digit identifier, indicating the type of query, the same reply: standard query, reverse (inverse) query, service status query, etc.;
  • AA: authoritative answer authoritative answer;
  • RD: expect recursion...
  • QDCOUNT:query的name、type;
  • ANCOUNT: Response RRs (message records);

The format of the request is the same as the corresponding message. The Wireshark packet capture example is as follows:

4. Other

When registering a domain name, the TLD authority inserts two records into the nameservers:

(域名,解析该域名的服务器域名,NA)

(解析该域名的服务器域名,IP,A)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324710457&siteId=291194637