Alibaba Cloud DNS Core Concepts and Applications

1. Basic concepts of DNS resolution

Official DNS documentation: https://help.aliyun.com/document_detail/102237.html

1.1. Basic introduction to DNS

DNS is the abbreviation of Domain Name System (Domain Name System), which 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 without having to remember An IP number string that can be read directly by the machine.

When we access an application system, before using DNS, we always use IP to access. The composition of IP is all numbers, which is difficult to remember. DNS can resolve IP into a domain name that is easy to remember, such as jiangxl.com. When browsing Enter jiangxl.com in the browser to jump to the corresponding application server to provide us with services. Compared with IP, the domain name is very easy to remember.

DNS core functions

  • Record the correspondence between domain names and IPs
  • Through DNS, the IP that often needs to be changed can be fixed as an access entry, even if the IP is changed, the user will not be aware of it.

Classification of DNS

  • Public network DNS (WAN) can access any Internet application through this type of DNS.
  • Private network DNS (bind9) This type of DNS can only be used in the LAN environment.

A typical DNS migration scenario is shown in the figure below

When our MySQL database needs to be migrated, and the database is migrated from Shanghai to the Beijing computer room, the IP must be changed. When the IP is changed, the program connecting to the database needs to be modified to a new IP. If we have fewer WEB nodes, it is ok Receive, if we have dozens of WEB nodes or even go on stage, it will be very troublesome for us to modify the program connections one by one. Even if we have an automated update process, it will take a long time and involve restarting the WEB program.

In view of this situation, we can write the IP and domain name of the database into a book, which is convenient for program memory. This book is the /etc/hosts file, which can record the correspondence between the domain name and the IP. We set a The domain name, such as mysql.example.com, writes the corresponding relationship between the IP of the database and the domain name into the /etc/hosts file. When we need to change the IP of the database, we only need to correspond to the domain name in /etc/hosts of each server The IP can be modified to complete the migration, and the program does not need to be restarted.

Although the IP and domain name are written into a file and the file can be modified, the process will become cumbersome if faced with thousands of servers.

For new problems, it is necessary to apply a DNS server. Deploy a DNS server in the server environment, record the corresponding relationship between the database IP and the domain name in the DNS server, and enable the for forwarding configuration in the DNS, and then configure each WEB server Specify the address of the local DNS in . When our program needs to connect to the database, it will find the address that provides MySQL services through DNS. When accessing the Internet, it will also be forwarded to the public network DNS server through the for configuration. When we need to change the database IP, just You can directly modify the DNS domain name resolution records to complete.

image-20220126141140184

Several key technical terms of DNS

  • DNS cache

    • DNS cache is also CDN. Before using CDN, you must understand DNS. DNS cache is to store the parsed data in the network node closest to the user. The ultimate goal is to allow users to reduce the speed of iterative queries, thereby speeding up website access.
  • TTL

    • The full name of TTL is Time To Live. This value is used to set the time for caching domain name resolution results. After the time expires, the resolution records will be automatically deleted, and recursive and iterative queries need to be performed again when used again.
  • TLD Server

    • TLD server
  • DNS Resolver

    • local DNS server
  • Root Server

    • root domain server

1.2. Hierarchical structure of domain names

There are many users using domain names on the Internet. When naming, the Internet divides domain names into four layers: root domain, top-level domain, main domain name, and subdomain name.

There are only 13 root domain servers in the world, and there is only one root domain, which is the dot ".". The DNS resolution process first arrives at the root domain.

Top-level domains are our common .com, .cn, .edu, etc. These domain names are collectively called top-level domain names, and all users can apply for the main domain name on the basis of top-level domain names.

The main domain name is also called the first-level domain name, such as the main domain name jiangxl.com, each user needs to apply for his own first-level domain name on the basis of the top-level domain name, and each individual and each enterprise has an independent main domain name.

Sub-domain names are what we often refer to as second-level domain names or host headers. Applying for second-level domain names on the basis of the main domain name can apply for different second-level domain names for different applications. For example, the domain name www.jiangxl.com is in A secondary domain name applied for based on the primary domain name.

In addition, there are also third-level domain names. The third-level domain name depends on the needs of individuals and enterprises. You can apply for a third-level domain name on the basis of the second-level domain name. For example, cn201212.www.jiangxl.com.cnthis domain name is usually used in different areas for an application. Regions can be distinguished by different third-level domain names.

image-20220126144357503

1.3. DNS resolution principle

Take the user accessing the www.jiangxl.com domain name as an example to explain the DNS resolution principle.

1) The user enters "www.jiangxl.com" in the browser. If there is a domain name resolution record in the /etc/hosts file, it will be returned to the user directly. If there is no local resolution record, the local DNS server will start a recursive query .

2) The local DNS server has no domain name resolution records, so iterative query is used to find the root domain server, and the root domain server is asked "do you know who is .com".

3) The root domain server tells the local DNS server that I know who the ".com" domain name is, and informs the local DNS server of the .com server information.

4) The local DNS server finds the top-level domain server of "com" according to the information, and starts asking if you know who "jiangxl.com" is.

5) The top-level domain server says that I know who "jiangxl.com" is, and informs the local server of the server information of the "jiangxl.com" domain name.

6) The local server finds the main domain server of "jiangxl.com" according to the information, and starts asking if you know who "www.jiangxl.com" is.

7) The main domain server says that I know who "www.jiangxl.com" is, and informs the local server of the "www.jiangxl.com" domain name server information.

8) After the local DNS gets the server information corresponding to the "www.jiangxl.com" domain name, it will feed back the resolution record to the client.

9) The browser sends an HTTP request to the WEB server corresponding to "www.jiangxl.com" according to the analysis record.

10) The WEB server presents the result in the user's browser.

insert image description here

1.4. The difference between DNS recursive query and iterative query

DNS query is divided into recursive query and iterative query.

  • recursive query

    • It means that when the DNS server receives the request initiated by the user, it must return an accurate query result to the user. If the DNS server does not store corresponding information locally, the server needs to query other servers and submit the returned query structure to the user.
    • In short, the recursive query must return an accurate resolution address to the user, and if the record does not exist in the searched server, other servers need to be asked
    • Recursive query is like the leader arranges a thing at work, regardless of the process, as long as the final result.
  • iterative query

    • It means that when the DNS server receives the request initiated by the user, it does not directly reply to the query result, but tells the address of another DNS server, and the user then submits the request to this DNS server, and this is repeated in turn until the query result is returned.
    • In short, iterative query means that the current server does not know the parsing record, but the server knows which server owns the record and informs the information.
    • Iterative query is like at work. You have to deal with a problem and ask your colleagues. Your colleague said that I don't know, but the leader must specify that you should ask the leader.

The effect diagram of recursive query and iterative query is as follows. The blue line represents recursive query, which needs to be returned to the client directly. The black line represents iterative query, and the query is performed layer by layer.

In the resolution process of DNS, the user and the local server directly use recursive query, and the local server directly uses iterative query with other servers.

image-20220126160755933

1.5. DNS commonly used resolution records

A record: resolves the domain name to the specified IPV4 address.

CNAME: resolve the domain name to another domain name, and another domain name provides specific services

AAAA: resolve domain name to IPV6 address.

NS: Specify the domain name to another DNS server for resolution.

MX: resolve the domain name to the mailbox server.

2. Use DNS cloud resolution to bind the domain name with the SLB public network IP

2.1. Enter the Alibaba Cloud DNS console

Find Alibaba Cloud DNS in the console, and click to enter the console of Alibaba Cloud DNS.

1642477916630

2.2. Add domain name resolution records

1) Find our domain name in Domain Name Resolution, click Resolution Settings.

1642478029543

2) Click Add Record —> record type is A record —> fill in the host name in the host record —> the record value is the public network address of SLB, which is the address to be resolved by the domain name.

1642482365652

2.3. Verify that the parsing is in effect

After the analysis is added, we can ping our domain name in the local cmd, and from now on, we can directly access our program through the domain name in the browser.

1642482879745

Guess you like

Origin blog.csdn.net/weixin_44953658/article/details/132355324