Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of DNS access

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What is the principle of DNS access? in view of this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Two days ago, I met an interviewer who said that the interviewer had a good chat with him and inadvertently talked about the process of DNS request. He casually dealt with a few words for a moment, although the other party had no intention of asking questions, but the final interview result was not satisfactory. With the attitude of learning while interviewing, let's take a look at the definitions and principles involved in the DNS request process. The meaning and structure of DNS

As we all know, IP is used to identify a server in the Internet. Although the IP address can represent a device, it is difficult to remember, so it is replaced with a name that can be understood and recognized, which we call the domain name. For example, www.51cto.com is a domain name, and an IP address is defined after the domain name to point to the website server. So the question is, who will do the correspondence from the domain name to the IP address? The answer is through DNS.

DNS is the Domain name system (Domain Name System, abbreviation: DNS) is a service of the Internet. It maps domain name and IP address to a distributed database, and saves the comparison relationship between domain name and IP in the database, which makes it more convenient for people to access the Internet.

DNS parsing is distributed storage and structurally the top level is the root domain name server (ROOT DNS Server), which stores the IP addresses of 260 top-level domain name servers. For Ipv4, there are 13 root domain name servers around the world, which stores resolution and domain name server address information for each domain, such as .com .net .cn. To put it simply, the root domain name server holds the address of the top-level domain name server.

Top-level domain name is also called first-level domain name. Top-level domain name can be divided into three categories, namely gTLD, ccTLD and New gTLD:

GTLD: international top-level domain names (generic top-level domains,gTLD), such as .com / .net / .org, all belong to gTLD

CcTLD: national and regional top-level domain name (country code top-level domains, referred to as ccTLD), for example: China is a .cn domain name, Japan is a .jp domain name

New gTLD: new top-level domain name (New gTLD), such as .xyz / .top / .red / .help.

The top-level domain name server stores the corresponding data of domain name IP according to the above three types.

At the level below the top-level domain name server, the local domain name server (Local DNS) is generally the DNS of the operator, and its main function is to represent users for domain name analysis.

As shown in figure 1, the DNS domain name server is divided into three levels: root domain name server (Root DNS Server), top-level domain name server (gTLD, ccTLD, New gTLD), and local domain name server (Local DNS Server).

Figure 1 DNS hierarchical structure

DNS parsing principle after talking about the structure of DNS, let's talk about its operation principle. Through the process of users visiting the web page, the whole process of DNS parsing and obtaining URL-to-IP mapping is described. Among them, the process is more complex, and there will be information transmission back and forth. In the process of drawing, we will simplify the line segments in which the information is transmitted back and forth, focus on the path of information transmission, and interpret the DNS parsing process through 9 steps.

Figure 2 the whole process of user request and DNS parsing

1. The user requests to enter the address to visit the website through the browser, for example: www.51cto.com. The browser looks for the IP address corresponding to URL in its own cache. If you have previously accessed and saved the cache of the IP address corresponding to this URL, then access the IP address directly. If there is no cache, proceed to step 2.

2. Through the local Host file configuration of the computer, you can set the mapping relationship between URL and IP addresses. For example, the windows file is set through the C:\ windwos\ system32\ driver\ etc\ hosts file, while the / etc/named.confg file is used in linux. Look for the local Host file here to see the cache with the IP address. If the mapping is still not found in the file, proceed to step 3.

3. Request Local DNS Server to obtain the mapping relationship between URL and IP through the local operator. If in the campus network, the DNS server is in the school, if it is the community network, the DNS server is provided by the operator. In short, the server is physically close to the computer that initiated the request. Local DNS Server caches a large number of DNS parsing results. Because of its good performance and close physical distance, it usually returns the resolution result of the specified domain name in a very short time. 80% of the DNS parsing requirements are met at this step. If the DNS parsing is not completed at this step, proceed to step 4

4. After parsing through Root DNS Server, ROOT DNS Server will return the address of the Local DNS Server top-level domain name server according to the requested URL. For example, if you query the domain name of ".com", you will query the address of the domain name server corresponding to gTL.

5. After returning the address of the top-level domain name server, access the corresponding top-level domain name server (gTLD, ccTLD, New gTLD), and return the Name Server server address. This Name Server is the domain name server registered by the website, which contains the corresponding information of the website URL and IP. For example, if you apply for a domain name from a domain name service provider, the domain name will be resolved by their server. This Name Server is maintained by the domain name provider.

6. Name Server will return the A record or CNAME of the specified domain to Local DNS Server, and set a TTL.

An A (Address) record is an IP address record that specifies the hostname (or domain name). Users can point the website server under this domain name to their own web server. At the same time, you can also set the secondary domain name of your domain name. CNAME: alias record. This record allows you to map multiple names to another domain name. Typically used for computers that provide both WWW and MAIL services. For example, there is a computer called "host.mydomain.com" (A record). It provides both WWW and MAIL services in order to facilitate user access to the service. Service providers generally recommend that users use CNAME records to bind domain names from the point of view of easy maintenance. If the host uses a two-wire IP, it is obviously more convenient to use CNAME. TTL (Time To Live): that is, to set the expiration time of this DNS resolution on Local DNS Server. After this expiration time, the mapping between URL and IP is deleted, and the Name Server needs to be obtained and requested.

7. If the A record is obtained at this time, you can directly access the IP of the website. But usually large websites return CNAME and pass it on to GTM Server.

GTM (short for Global Traffic Manager) is global traffic management, which is based on intelligent DNS and distributed monitoring system to achieve real-time failover and global load balancing to ensure the continuous high availability of application services. The purpose of passing it to GTM is to help users find the most suitable server IP through the load balancing mechanism of GTM.

That is, the one closest to you, the one with the best performance and the healthiest server. And most websites do CDN caching, so you need to use GTM to help you find the CDN cache server suitable for you in the network nodes.

8. After you find the CDN cache server, you can get some static resources directly from the server, such as HTML, CSS, JS and pictures. But some dynamic resources, such as commodity information and order information, need to go through step 9.

9. Dynamic resources without cache need to be obtained from the application server, and there is usually a layer of load balancer responsible for reverse proxy between the application server and the Internet. It is routed to the application server.

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

The supplier applying for the domain name will provide Name Server as DNS resolution. From the user to visit 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, Application Server.

The answer to the question about the principle of DNS access is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report