DNS domain name resolution service

Directory

1. DNS system

1. The meaning of DNS

2. The protocol and port number used by DNS

3. The role of the DNS system

4. DNS system type

5. The method of DNS query

6. The process of DNS resolution

2. Basics of BIND domain name service

1. Forward analysis

2. Reverse analysis


1. DNS system

1. The meaning of DNS

DNS domain name system (Domain Name System abbreviated as DNS, Domain Name is translated as a domain name) is a core service of the Internet. As a distributed database that can map domain names and IP addresses to each other, it can make it easier for people to access the Internet. Instead of remembering the IP number string that can be read directly by the machine.

2.DNS protocol and port number

  • The default port for DNS is 53. DNS port is divided into TCP and UDP.
  • TCP is used for zone transfer, mostly for master-slave synchronization.
  • UDP is used for DNS resolution.

3. Function of DNS system

  • Forward resolution: find the corresponding IP address according to the domain name
  • Reverse analysis: Find the corresponding domain name according to the IP address
  • Distributed Data Structure of DNS System

  1. “There are only 13 root domain name servers in the world (the names of these 13 root domain name servers are “A” to “M”), and 1 is the main root server in the United States. The remaining 12 are auxiliary root servers, of which 9 are in the United States and 2 in Europe. 1 in the UK and Sweden, and 1 in Japan in Asia.

  2. domain name structure

  • http://www.sina.com.cn./: http://hostname.subdomain.second-level domain.top-level domain root domain/

root domain:

  • It is located at the top level of the domain name space, generally represented by a “.”.

TLD:

  • Typically represents a type of organization or country.
  • Such as: net (network provider), .com (industrial and commercial enterprises), .org (group organization), .edu (educational institution), .gov (government department), .cn (China’s national domain name).

Second level domain:

  • It is used to indicate a specific organization in the top-level domain, and the second-level domain name under the national top-level domain is managed by the national network department.
  • Such as the second-level domain name set under the .cn top-level domain name: .com.cn, .net.cn, .edu.cn.

Subdomains:

  • All levels of domains created under the second-level domain are collectively referred to as sub-domains, and each organization or user can freely apply for and register their own domain names.

the host

  • The host is located at the bottom of the domain name space, which is a specific computer.
  • For example, www and mail are specific computer names, which can be represented by www.sina.com.cn. and mail.sina.com.cn. The full name in the domain name.

4. DNS system type

  • caching nameservers
  1. Also known as DNS cache server
  2. Obtain domain name -> IP address record by querying other domain name servers
  3. Cache domain name query results locally to improve the speed of repeated queries
  • primary nameserver
  1. Authoritative server for a specific DNS zone, unique
  2. Responsible for maintaining all domain name->IP address mapping records in the region
  3. It is necessary to create the address data file of the responsible area by itself
  • from nameserver
  1. Also known as a secondary domain name server, it is a hot backup for the primary domain name server
  2. The domain name -> IP address record it maintains comes from the main domain name server
  3. The zone address database needs to be automatically synchronized from the master nameserver

5. DNS query method

  • recursive query

Recursive query is a query mode of DNS server, in which DNS server receives a request from a client and must reply to the client with an accurate query result. If the DNS server does not store query DNS information locally, the server will query other servers and submit the returned query results to the client. After the client sends the request, it only needs to wait for the result, and the specific process in the middle is handed over to the server for implementation.

  • iterative query

Another query method of the DNS server is iterative query. When the client sends a query request, the DNS server does not directly reply to the query result, but tells the client the address of another DNS server, and the client then submits a request to this DNS server. , looping in turn until the results of the query are returned. The client’s request needs to be queried one by one to get the result. When the server has no result, it will only provide you with the address of other servers, and will not help you to request the query. This is the opposite of recursion.

6.DNS resolution process

  1. Check the cache record of the machine first.
  2. Query the hosts file.
  3. Query the dns domain name server and hand it over to the dns domain name server for processing.
  4. This dns server may be a local domain name server, and there is also a cache. If there is a result, it will return the result directly, if not, go to the next step.
  5. Ask the root domain server for help, and the root domain server returns the top-level domain server that may know the result and asks him to find the top-level domain server.
  6. Ask the top-level domain server for help, the top-level domain server returns the second-level domain server that may know the result, and then he goes to the second-level domain server.
  7. Ask the secondary domain server for help. The secondary domain server finds out that it is my host, and returns the queried IP address to the local domain name server.
  8. The local domain name server records the result to the cache, and then returns the correspondence between the domain name and IP to the client.

2. Basics of BIND domain name service

/etc/named.conf
# main configuration file
  
/etc/named.rfc1912.zones
#Regional configuration file

1. Forward analysis

  • Find the corresponding IP address based on the host name (domain name)

Modify the main configuration file

Modify the zone configuration file and add forward zone configuration

Configure forward zone data files

Add the DNS server address in the domain name resolution configuration file of the client

Test DNS resolution

2. Reverse analysis

Modify the zone configuration file and add reverse zone configuration

Configure reverse zone data files

Test DNS resolution