[Computer Network] More than 10,000 words to explain clearly "DNS of Network Protocol"

DNS of network protocol

The Domain Name System (English: Domain Name System, abbreviation: DNS) is a service of the Internet. As a distributed database that maps domain names and IP addresses to each other, it can make it easier for people to access the Internet. DNS uses TCP and UDP port 53. Currently, the limit for the length of each level of domain name is 63 characters, and the total length of the domain name cannot exceed 253 characters.

Keywords: DNS, domain name resolution

What is DNS?

DNS is an application layer protocol.

The role of the Domain Name System (DNS) is to convert a human-readable domain name (for example, www.example.com) into a machine-readable IP address (for example, 192.0.2.44).

What is a domain name?

A domain name is a string delimiter dot .name on the Internet composed of a computer or group of computers for identifying the azimuth data transmission computer. A domain name can be said to be a proxy for an IP address, in order to make it easier to remember the latter. For example, wikipedia.org is a domain name, which corresponds to the IP address 208.80.152.2. People can directly visit wikipedia.org to replace the IP address, and then the Domain Name System (DNS) will convert it into an IP address that is easy for machines to recognize. In this way, people only need to memorize the string of characters with special meaning on wikipedia.org, instead of memorizing the meaningless numbers.

Insert picture description here

Layering of DNS

The domain name system is hierarchical.

In the hierarchical structure of the domain name system, various domain names are subordinate to the root domain of the domain name system. The first level of the domain name is the top-level domain, which includes generic top-level domains, such as .com, .netand .org; and country and regional top-level domains, such as .us, .cnand .tk. The next level of the top-level domain name is the second-level domain name, level by level down. These domain names provide people with registration services, and people can use them to create public Internet resources or run websites. The management service of the top-level domain name is handled by the corresponding domain name registry (domain name registry), and the registration service is usually handled by the domain name registrar.

DNS service type

  • Authorized DNS -An authoritative DNS service provides an update mechanism for developers to use to manage their public DNS names. Then, it responds to DNS queries and converts the domain name to an IP address so that the computers can communicate with each other. The authoritative DNS has the ultimate authority for the domain and is responsible for providing the recursive DNS server's response to the IP address information. Amazon Route 53 is an authoritative DNS system.
  • Recursive DNS -Clients usually do not directly query authoritative DNS services. Instead, it usually connects to other types of DNS services called resolvers, or recursive DNS services. A recursive DNS service is like a hotel concierge: although it does not have any DNS records of its own, it can act as an intermediate program to obtain DNS information on your behalf. If a recursive DNS has a DNS reference that has been cached or stored for a period of time, it will respond to DNS queries by providing source or IP information. If not, it will pass the query to one or more authoritative DNS servers to find the information.

Record type

In DNS, common resource record types are:

  • NS Record (Domain Name Service) ─ Specify the DNS server that resolves the domain name or subdomain name.
  • MX record (mail exchange) ─ Specify the mail server to receive messages.
  • A record (address) -the IPv4 address record corresponding to the specified domain name.
  • AAAA record (address) ─ Specifies the IPv6 address record corresponding to the domain name.
  • A CNAME (specification) ─ a domain name or domain name is mapped to another CNAMErecord (example.com point www.example.com ) or mapped to a Arecord.
  • PTR record (reverse record) ─ PTR record is used to define the name associated with the IP address. The PTR record is the inverse of the A or AAAA record. PTR records are unique because they start with the .arpa root and are delegated to the owner of the IP address.

For details, please refer to: Wikipedia-Domain Name Server Record Type List

DNS

There are two ways to map hostname to IP address:

  • Static mapping -configure the domain name and IP mapping on this machine, which is intended to be used on this machine. The content in the hosts file of Windows and Linux belongs to static mapping.
  • Dynamic mapping -Establish a set of domain name resolution system (DNS), only configure the host-to-IP address mapping on a dedicated DNS server. For devices on the network that need to use host names to communicate, first need to query the IP address of the host from the DNS server .

The process of querying the domain name server by domain name and obtaining the IP address is called domain name resolution. When resolving a domain name, the static domain name is generally resolved first, and then the domain name is dynamically resolved. Some commonly used domain names can be put into the static domain name resolution table, which can greatly improve the efficiency of domain name resolution.

Insert picture description here

The figure above shows a process of dynamic domain name resolution, the steps are as follows:

  1. The user opens a web browser, enters www.example.com in the address bar, and then presses Enter.
  2. The request for www.example.com is routed to a DNS resolver, which is generally managed by the user's Internet service provider (ISP), such as a cable Internet service provider, DSL broadband provider, or corporate network.
  3. The ISP's DNS resolver forwards the request for www.example.com to the DNS root name server.
  4. The ISP's DNS resolver again forwards the request for www.example.com, this time to a TLD name server in the .com domain. The name servers for the .com domain use the names of the four Amazon Route 53 name servers related to the example.com domain to respond to the request.
  5. The ISP's DNS resolver selects an Amazon Route 53 name server and forwards the request for www.example.com to that name server.
  6. The Amazon Route 53 name server looks up the www.example.com record in the example.com hosted zone, obtains the relevant value, for example, the IP address of the web server (192.0.2.44), and returns the IP address to the DNS resolver.
  7. The ISP's DNS resolution program finally obtains the IP address that the user needs. The parser returns this value to the web browser. The DNS resolver will also cache (store) the IP address of example.com for the length of time you specify so that it can respond more quickly the next time someone visits example.com. For more information, see Time To Live (TTL).
  8. The web browser sends a request for www.example.com to the IP address obtained from the DNS resolver. This is where your content is located, for example, a web server running in an Amazon EC2 instance or in an Amazon S3 bucket configured as a website endpoint.
  9. The web server or other resource on 192.0.2.44 returns the web page of www.example.com to the web browser, and the web browser displays the page.

Note: Domain name resolution can only be performed if the domain name server is configured.

For example, in Linux execute vim /etc/resolv.confthe command, in which add the following to configure the DNS server address:

nameserver 218.2.135.1

Domain related commands on Linux

hostname

The hostname command is used to view and set the host name of the system. The environment variable HOSTNAME also saves the current host name. After using the hostname command to set the host name, the system will not permanently save the new host name, and the original host name will remain after the machine is restarted. If you need to modify the host name permanently, we need to modify /etc/hostsand /etc/sysconfig/networkrelevant content.

Reference: http://man.linuxde.net/hostname

Example:

$ hostname
AY1307311912260196fcZ

nslookup

The nslookup command is a commonly used domain name query tool, which is a command used to check DNS information.

Reference: http://man.linuxde.net/nslookup

Example:

[root@localhost ~]# nslookup www.jsdig.com
Server:         202.96.104.15
Address:        202.96.104.15#53

Non-authoritative answer:
www.jsdig.com canonical name = host.1.jsdig.com.
Name:   host.1.jsdig.com
Address: 100.42.212.8

more content

Guess you like

Origin blog.csdn.net/weixin_54707168/article/details/115024331