Traditional Culture Encyclopedia - Traditional stories - Teach you how to understand DNS in 5 minutes
Teach you how to understand DNS in 5 minutes
DNS, also called Domain Name System, is a service of the Internet.
It is essentially a distributed database that maps domain names and IPs to each other. With it, we can access the Internet more conveniently through domain names.
DNS features are distributed, the protocol supports TCP and UDP, the commonly used port is 53, the length limit of each level of domain name is 63, and the total length limit of the domain name is 253.
In the earliest days, the upper limit of DNS UDP packet size was 512 bytes, so when a response size exceeded 512 (too much returned information), the DNS service would use the TCP protocol for transmission.
Later, the DNS protocol expanded its own UDP protocol. When the DNS client issues a query request, it can specify that it can receive UDP packets exceeding 512 bytes. In this case, DNS will still use the UDP protocol.
Hierarchical database structure: The structure of DNS is very similar to the Linux file system, like an inverted tree.
The following uses the domain name of Webmaster Home as an example: the top . is the root domain name, followed by the top-level domain name, then the domain name chinaz of Webmaster Home, and so on.
When working with domain names, work from the bottom up.
s.tool.chinaz is a complete domain name, as is www.chinaz.
The reason why such a complex tree structure is designed is to prevent name conflicts.
Such a tree structure can of course be stored on one machine, but in the real world there are many complete domain names, and a large number of domain names are added and deleted every day. If they exist on one machine, the storage performance of a single machine is
No small challenge.
In addition, another disadvantage of centralized management is that the management is not flexible enough.
You can imagine how troublesome it is to apply to the central database every time you add or delete a domain name.
Therefore, DNS in reality is distributed storage.
The root domain name server only manages top-level domains and delegates the management of each top-level domain to each top-level domain. So when you want to apply for a second-level domain name, just look for the domain name registration center.
Second-level domain names, and domain names below are yours to manage.
When you manage, .us.
When a general company applies for a public domain name, if it is a multinational product, it should choose a generic top-level domain name.
If you don’t have cross-border business, it depends on your preferences (you can compare the services, stability, etc. of various top-level domains before making a choice).
Here are some popular top-level domains. For complete top-level domains, see Wikipedia.
The meme top-level domain is actually a national domain name, which is the national domain name of Montenegro and Japan. However, it is applied for personal development, so many personal bloggers use it as their blog domain name.
Many open source projects often use io as the top-level domain name, which is also a national domain name.
Because io has the same abbreviation as input/output in the computer, and is also very similar to the second mechanism of the computer, it gives people a geek feeling.
Compared with .domain name, .io has many resources and more choices.
DNS resolution process: After talking about the basic concepts of DNS, let’s talk about the DNS resolution process.
When we access the Internet through a browser or application, the DNS resolution process will be performed first.
Standard glibc provides the libresolv.so.2 dynamic library, which our application uses for domain name resolution (also called resolving). It also provides a configuration file /etc/nsswitch.conf to control the resolving behavior. In the configuration file
The most critical thing is this line: hosts: files dns myhostname.
It determines the order of resolving. By default, the hosts file is searched first. If no match is found, DNS resolution is performed.
The default resolution process is as follows: The above figure mainly describes the resolution process on the client side. We can see that the most important step is to request the local DNS server to perform resolving. It will send a resolution request to the recursive resolution according to the local DNS server configuration.
Server (what is a recursive resolution server will be introduced later), the local DNS server is configured in /etc/resolv.conf.
Let's take a look at the resolving process on the server side: Let's analyze the parsing process: the client sends a request to resolve the //tool.chinaz domain name to the local DNS server (recursive resolution server), and the local dns server checks the cache to see if it has been cached //
tool.chinaz domain name, if there is one, it will be returned directly to the client; if there is no one, go to the next step.
- Previous article:What are the best educational toys for 4-12 year olds?
- Next article:How about the art program of the North Institute of Technology ah
- Related articles
- Characteristics of plum bottles in different dynasties
- What are the 18 kinds of cold weapons in ancient times?
- Request Arabic Songs
- Knowledge points of ninth grade morality and rule of law
- How to improve the welding efficiency of spot welding machine
- Find an English composition about the influence of western festivals on teenagers in China.
- Nanyang printing Nanyang printing house?
- What is the logistics from Suzhou to Shanghai?
- Inheritance of Nantong kites
- Why can't dogs be kept for eight years?