We all know that a computer needs to know the IP address of a computer to send a message to another computer. But IP addresses are long strings of numbers that are easy for programs to understand, but difficult for humans to remember.
In order for the IP address to be used properly by humans, it needs to have a human Name, which is called a Domain Name.
Of course, the domain name is not arbitrary, the name is to distinguish between themselves and others, but also to show their connection with others. Surname, for example, distinguishes the so-called kindred. Another example is generational inheritance, where the same generation has to have one word in their name.
The same is true for domain names. The last name is TLD (top level domain). All domain names come down from the top level domain. Top-level fields generally identify some basic categories, such as com, which is the most common, for commercial sites, and EDU, for educational sites.
Top-level domain name below, can be divided layer by layer, there can be second level domain name (SLD), three level domain name, and even four level five domain name. But the general common domain name is also three levels.
Another interesting point is that domain names are actually viewed from right to left. For example, the most common domain name of Baidu: Baidu.com, in fact, you should look at COM first and then baidu.
Domain names can be reused, if we want to build a website, we need to buy a domain name (which is provided by the domain name service provider), but we only buy the right to use the domain name, after the expiry date, we need to buy again. If not enough to buy, the domain name can be given to others to use.
Now that we know the domain name, how do we get the IP address from the domain name?
When we type a URL into a browser, the browser first looks for the corresponding domain name and IP address in its cache. If it doesn’t, the browser calls the operating system, and the operating system checks its cache to see if it has that information.
If not, the operating system sends a resolver. Resolver will first ask the root server if it has such information.
By the way, the root server is the top layer of DNS, and there are 13 of them (but there are many duplicates, so look-ups will take precedence over look-ups on the nearest root server).
The root server will return the TLD message to the Resolver. The Resolver will save the message and go to the TLD. The TLD will send it to the authoritative Name Server, Then the Name Server tells it what the IP address is. The Resolver gets the IP address and passes it to the OS, which stores the result (with less effort next time) and sends it to the browser, which gets the IP address and can connect.
The resolver is formally named a resolving Name Server for resolving IP addresses. During its query, it saves the results each time so it doesn’t have to go back to find them.
Now, let’s go into a little more detail. Resolver works with the root server, TLD, etc. How does the root server know this information?
In fact, each server has zone file inside which there are many records. All domain names known by a name server are stored in the file as records. Of course, record also has more than a domain name and IP correspondence, but also contains other finer things, want to refer to can look at the bottom of the reference file.
Reference:
What is a domain name?
An Introduction to DNS Terminology, Components, and Concepts
How DNS Works