<> Domain name system DNS
Domain name system DNS Is the naming system used by the Internet , It is used to translate machine names that are convenient for people to IP address .
In the early days, there were only hundreds of computers on the whole network , It was called hosts Documents of , List all host names and the corresponding IP address . As long as the user enters a host name , The computer can quickly convert the host name into binary that the machine can recognize IP address .
Domain name system of Internet DNS Designed as an online distributed database system , And adopt client server mode .
Domain name to IP The key points of address resolution are as follows
： When an application process needs to resolve the hostname to IP Address time , The application process calls the resolver , And become DNS A customer of , Place the domain name to be resolved in DNS In the request message , with UDP User datagram sent to local domain name server （ use UDP To reduce costs ）. After the local domain name server finds the domain name , Put the corresponding IP Return the address in the reply message . The application process obtains the IP After the address, you can communicate .
Domain name structure
Tertiary domain name . Secondary domain name . First level domain name
DNS The domain tree of is composed of , Top level domain , Composition of secondary domain and its subdomains , Its structure and example are as follows :
1) Root domain server ： The root domain name server is the highest level domain name server , It is also the most important domain name server . All root domain servers know the domain names and IP address .
No matter which local domain name server , To resolve any domain name on the Internet , As long as you can't parse , First, ask for help from the root domain server .
2） Top level domain name server
： These domain name servers are responsible for managing all secondary domain names registered with this top-level domain name server . When received DNS When querying a request , Give corresponding answers （ It could be the end result , It may also be the domain name server that should be found in the next step IP address ）.
3） Permission domain name server when a permission domain name server is not able to give the final query answer , It will tell you to send out the query request DNS customer , Which domain name server should I find next .
4） Local domain name server
Does not belong to the domain name server hierarchy shown above , But it's very important for the domain name system . When a host sends out DNS When querying a request , This request message is sent to the local domain name server , This kind of domain name server is also called the default domain name server .
You can see the preferred DNS Server and standby DNS Server's IP address , there DNS Server refers to the local domain name server .
In order to improve the reliability of domain name server ,DNS Domain name servers copy data to several domain name servers to save , One of them is the primary domain name server （master name
server）, The other is the secondary domain name server （secondary name server）, ensure DNS No consistency between terminal and data .
<>DNS Domain name resolution process
The query from the host to the local domain name server is generally recursive , The query from local domain name server to root domain name server usually adopts iterative query
： If the local domain name server queried by the host does not know the IP address , Then the local domain name server DNS Identity of the customer , Continue to issue query request to other root domain name servers （ Replace the host to continue the query ）, Instead of letting the host do the next query on its own . therefore , Result returned by recursive query or requested query IP address , Or report a mistake , Indicates that you cannot find the required IP.
： When the root domain name server receives the iterative query request message from the local domain name server , Either give the IP address , Or tell the local domain name server “ Which server should I query next ”. Then let the local domain name server perform subsequent queries （ Instead of making subsequent queries for the local domain name server ）.
1. The root domain name server usually uses the top-level domain name server it knows IP Address to local domain name server , Let the local domain name server query the top-level domain name server again
2. After receiving the query request from the local domain name server, the top-level domain name server , Or give what you want to wipe away IP address , Or tell the local domain name server which authority domain name server to query next , Do iterative queries like this .
of course , Local domain name server can also use recursive query , It depends on which query mode is required when the initial query request message is set .
In order to improve DNS Query efficiency , And reduce the load of the root domain name system server and the DNS Number of query messages , Cache is widely used in domain name server
. Cache is used to store records of recently queried domain names and where to obtain domain name mapping information .
1, Enter in browser www.toutiao.com domain name , The operating system will check its local hosts Does the file have this URL mapping relationship , If any , Call this first IP Address mapping , Domain name resolution complete .
2, If hosts There is no mapping of this domain name in , Find local DNS Parser cache , Is there a URL mapping relationship , If any , Direct return , Domain name resolution complete .
3, If hosts And local DNS There is no corresponding URL mapping relationship in the parser cache , First of all TCP/IP Preferences set in parameters DNS The server , I.e. local DNS The server , When this server receives a query , If you want to query the domain name , Included in local configuration area resources , Then return the parsing result to the client , Domain name resolution complete , This resolution has
4, If you want to query the domain name , Not from local DNS Server zone resolution , But the server has cached this URL mapping relationship , Call this IP Address mapping , Domain name resolution complete , This resolution is not authoritative .
5, If local DNS Server local area file and cache resolution are invalid , Ask the root domain server for help . Because the root domain name server only records its subordinate's 13 Top level domain name servers , Instead of directly recording domain names and IP Mapping of , So when receiving the resolution request from the local domain name server , The root domain server will inform the local server ：“ The domain name you requested was .com Top level domain name server management , his IP by xxx”.
6. local DNS The server goes further to .com Top level domain name server initiates domain name resolution request , because .com Domain name server will not record domain name and IP Mapping of , Instead, the requester is told to go to the domain server where the domain name belongs for query , And give the IP address .
7. local DNS The server continues to initiate a header domain name resolution request to the domain server , You will get the corresponding IP address , At this time, local DNS The server will not only return to the user's computer IP address , At the same time, add the header domain name and its IP Records of , So as to speed up other computers to obtain the corresponding header domain names IP Analytical speed of