DNS definition and its function

Wikipedia explains DNS

The Domain Name System (DNS) is a service on the Internet. It acts as a distributed database that maps [domain name] and [IP address] to each other, making it easier to access the Internet. DNS uses TCP and UDP port 53. Currently, each level of a domain name is limited to 63 characters, and the total length of a domain name cannot exceed 253 characters.

The main function of DNS is to “translate” familiar web addresses (domain names) into IP addresses that computers can understand. This process is called DNS domain name resolution. For example, when we board baidu’s address, are to knock www.baidu.com, login, do you go to knock IP address board Baidu? Obviously, domain names are easy to remember.

DNS server

2.1 Domain Name Levels

Cloud resolution definitions:.com,.net,.cn, and.gov.cn are top-level domains.

Definition: abc.com, example.cn, and beijing.gov.cn are level-1 domain names.

Definition: www.abc.com, news.example.cn, and www.beijing.gov.cn are second-level domain names, that is, subdomain names of first-level domain names. The subdomain names are second-level subdomain names.

By analogy, subdomain levels are defined as follows:

The level 1 subdomain name is A. www.abc.com or A. www.beijing.com.cn.

The level 2 subdomain is: B.A. www.abc.com or B.A. www.beijing.com.cn;

Level 3 subdomains: C.B.A. www.abc.com or C.B.A. www.beijing.com.cn;

2.2 DNS Server types

ROOT DNS Server

The root DNS server is where the TOP-LEVEL DNS addresses are stored. Store 260 TOP-LEVEL domain name server IP addresses. For Ipv4, there are 13 root DNS servers in the world, which store the resolution and DNS address information for each domain (such as.com.

Top-level domain name server

For example, the domain name server of.com stores the authoritative DNS server addresses of some level 1 domain names (such as the DNS of toutiao.com).

Top-level domain names are also called level 1 domain names. Top-level domain names can be divided into three categories, namely gTLD, ccTLD and New gTLD:

  • GTLD: Generic top-level domains (gTLD), such as.com/.net/.org, belong to gTLD.
  • CcTLD: Country code top-level domains (ccTLD), for example,.cn in China and.jp in Japan.
  • New gTLD: New gTLD, such as.xyz/. Top /. Red /. Help

Local DOMAIN name Server (DNS)

The DNS of carriers is used to perform domain name analysis on behalf of users.

Principles of DNS resolution

3.1 Recursive query

Generally, the host queries the local DNS server recursively.

A recursive query is: if the host asked the local domain name server does not know the IP address of the domain name is query, then local domain name server in the DNS client identity, send a query request message to other root name servers to continue (for the host to query), and not let host himself into the next phase of the query.

Therefore, the recursive query returns the IP address to be queried or an error message indicating that the REQUIRED IP address cannot be queried.

3.2 Iterative Query

When receiving the iterative query request packet from the local DNS server, the root DNS server either gives the IP address to be queried or tells the local server which DNS server you should query next.

It then lets the local server perform subsequent queries. The root DNS server usually informs the local DNS server of the IP address of the TOP-LEVEL DNS server that it knows, and then the local DNS server queries the TOP-LEVEL DNS server.

After receiving the query request from the local DNS server, the TOP-LEVEL DNS server either provides the IP address to be queried or tells the local server which permission DNS server to query next.

Finally, the IP address to resolve is known or an error is reported, and the result is returned to the host that initiated the query.

Recursion: The client sends a request only once, asking the other party to give the final result.

Iteration: The client makes a request, and if the other party is not authorized to answer it, it returns a list of other name servers that can answer the query. The client makes further requests from the returned list until it finds the name server that is ultimately responsible for the requested domain name and gets the final result from it.

Authorization answer: Query the DNS server for a domain name. The DNS server is responsible for the domain name. The result is the authorization answer.

From recursive and iterative queries, we can see:

Client-local DNS server: This part is a recursive query. (definition)

Local DNS server — Extranet: This part is an iterative query.

When a recursive query is performed, only two results are returned: the query succeeded or the query failed.

An iterative query, also known as a redirect, returns the best query point or host address.

3.3 Detailed Process

For example, enter www.toutiao.com in the browser.

① The user requests to enter the address of the website to be accessed through the browser, for example, www.toutiao.com. The browser looks up the IP address of the URL in its cache. If you have accessed the IP address before, save the cache of the CORRESPONDING IP address of the URL, then directly access the IP address. If there is no cache, go to Step 2.

If not, ask the operating system, the operating system will also look at its cache, if there is, directly return.

③ You can set the mapping between URLS and IP addresses by configuring the Host file on the PC. For example, on Windows, it is set in the C:\windwos\system32\driver\etc\hosts file. On Linux, it is set in the /etc/named.confg file. The Host file has an IP address in the cache. If no mapping is found in the file, proceed to step 4.

4 Request the Local DNS Server and obtain the MAPPING between urls and IP addresses from the Local carrier. If it is on the campus network, the DNS server is on the campus; if it is on the cell network, the DNS server is provided by the carrier. In short, the server is physically close to the machine that initiates the request. The Local DNS Server caches a large number of DNS resolution results. Due to its high performance and physical proximity, it usually returns the resolution results of the specified domain name in a very short time. 80% of DNS resolution requirements are satisfied in this step. If the DNS resolution is not complete at this step, go to step 5.

⑤ If the Root DNS Server is used for parsing, the Root DNS Server returns the ADDRESS of the Local DNS Server based on the requested URL. For example, if you want to query the domain name of.com, query the ADDRESS of the DNS server corresponding to the gTL.

⑥ After returning the ADDRESS of the TOP-LEVEL domain Name Server, access the corresponding top-level domain Name Server (gTLD, ccTLD, and New gTLD) and return the address of the Name Server. Simply put, a Name Server records a domain Name and resolves the domain’s authoritative DNS.

⑦ The Name Server returns the A record or CNAME of the specified domain Name to the Local DNS Server and sets A TTL.

  • A (Address) record specifies the IP Address corresponding to the host name (or domain name). Users can point the web server under this domain name to their Own Web server. You can also set the secondary domain name of your domain name.
  • CNAME: indicates the alias record. This recording allows you to map multiple names to another domain name. A computer usually used to provide both WWW and MAIL services. For example, there is A computer named “host.mydomain.com” (A record). It provides both WWW and MAIL services for easy user access. From the perspective of convenient maintenance, service providers generally recommend users to use CNAME to record bound domain names. If the host uses a dual-line IP, it is obviously easier to use a CNAME.
  • TTL(Time To Live) : indicates the expiration Time of the DNS resolution on the Local DNS Server. When this expiration time is exceeded, the MAPPING between URL and IP is removed and the Name Server needs to be fetched.

⑧ If this is A record, then you can directly access the website IP. But typically large web sites will return a CNAME and pass it to GTM Server.

Global Traffic Manager (GTM) is Global Traffic management. Based on intelligent DNS and distributed monitoring system, GTM implements real-time failover and Global load balancing to ensure continuous high availability of application services. The purpose of sending the IP address to GTM is to help users find the most suitable server IP address through the load balancing mechanism of GTM.

That is, the closest, the best performance, the healthiest server. And most websites will do CDN cache, at this time, it is more necessary to use GTM to help you find a suitable CDN cache server in the network node.

⑨ After finding the CDN cache server, you can directly obtain some static resources from the server, such as HTML, CSS, JS, and images. However, some dynamic resources, such as commodity information and order information, need to pass step 9.

⑩ Dynamic resources that are not cached need to be obtained from application servers. A load balancer is usually deployed between the application server and the Internet for reverse proxy. It is routed to the application server.

Note: if you look closely at the procedure above, you may notice that there is no mention of how the DNS server knows the IP address of the “root DNS server”. The NS records and IP addresses of the root DNS server do not change, so they are built into the DNS server.

4. Forwarding mode and non-forwarding mode

In step 4, if the local DNS server cannot be queried, perform the query based on the forwarder configured on the local DNS server.

No forward mode: the local DNS sends the request to the root DNS for (iterative) query. The root DNS server receives the request and determines who is authorized to manage the domain name (.com) and returns an IP that is responsible for the top-level domain name server. When the local DNS server receives the IP information, it contacts the server responsible for the.com domain. The server in charge of the.com domain receives a request and if it cannot resolve the request itself, it will find a DNS server address of the next level that manages the.com domain and give it to the local DNS server. After receiving the IP address, the local DNS server searches for the domain name server and performs the preceding operations until it finds the host corresponding to the domain name.

Forward mode: The DNS server forwards the request to the upper-level DNS server for resolution. If the upper-level SERVER fails to resolve the request, the DNS server searches for the root DNS server or forwards the request to the upper-level DNS server. Whether the local DNS server forwards or root prompts, the result is eventually returned to the local DNS server, which in turn returns the result to the client.

4. To summarize

The DNS server is used for URL and IP address resolution to help users find the IP address to access the server. The STRUCTURE of DNS server is roughly divided into three layers: root DNS server, top-level DNS server, and local DNS server.

The provider applying for a domain Name will provide the Name Server for DNS resolution. From the moment the user visits a website, through the browser, Local Host file, Local DNS Server, Root DNS Server, top-level domain Name Server (gTLD, ccTLD, New gTLD), Name Server, GTM, CDN, and Application Server.