What is the DNS (Domain Name System)?
Every device on an IPv4/IPv6 network has a unique identifier, an address called IP address (Internet Protocol address), this address is useful for the device to be identified and reached by other devices. Users familiarized with IPv4 know IP addresses consists of 4 octets ranging between 0 and 255 like 126.96.36.199.
Every website or service we communicate with on the internet has a unique IP address which allows us to reach it accurately, for example, if we want to reach Google we are reaching the IP address 188.8.131.52.
For humans, remembering each IP address for each website or service we use is impossible, or at least not a friendly way to remember website addresses, and that’s where domain names, friendly to human users, such as LinuxHint.com came to our aid.
While each device has a unique IP address, every IP address can be associated with a domain name to ease its communication or exposure before humans.
Therefore, if you have a device from which you want to serve others, or you want to be found easily you can associate it with a human friendly name, called a domain name, these usually starting with www.
DNS (Domain Name System and NOT Domain Name Server) is the system through which domain names are translated into IP addresses. We can think about the Domain Name System as a translator from friendly www.domain.com to IPv4 addresses X.X.X.X (or IPv6 addresses too). And this “translation” process is called “DNS resolution”.
How the DNS (Domain Name System) works?
The Domain Name System (DNS) is achieved through 4 different types of servers: the DNS recursive resolver, the Root Name Server, the Top-Level Domain Name Server and finally the DNS Name Server.
The whole sequence can be summarized as:
Your Browser > DNS Recursive Resolver > Root Name Server > Top Level Domain Server > DNS Name Server.
The DNS Recursive Resolver is the first step of the DNS resolution process, it is the server which receives the user query to continue with the resolution process (also called DNS lookup). The DNS Recursive Resolver receives the user request for the domain name translation into IP address and passes the request to the Root Name Server, the DNS Recursive Resolver has a list containing all Root Name Servers addresses to find them.
The Root Name Server is the second step in the process and can resolve the request for the Recursive Resolver with the cached information or by delivering the request to the Top Level Domain (such as .com, .org, .net, .edu or .gov) which contains information on all domains belonging to that Top Level, so if the requested domain is a .com, the Top Level Domain server will be the .com TLD server and then the request is sent to the DNS server which contains the IP address, sends it to the Recursive Resolver which sends the client who requested the resolution the proper translation or resolution translated into an IP address.
The exception for the steps above is when a recent domain name resolution was saved in the cache by the Resolver.
The process described above is in many cases omitted due DNS caching, the Recursive Resolver, or the Root Server can store domain name server resolution information cached in order to increase performance preventing the whole process, in such cases the domain resolution will be faster and some of the servers mentioned above won’t intervene, that’s the reason why sometimes we update our DNS records in our hosting and changes take minutes or hours to take place, because DNS caches should refresh.
When a Recursive Resolver gets resolution information, it caches the information and it is used for next resolutions saving the whole process explained before.
Linux has a variety of commands to deal with DNS resolution you can find at https://linuxhint.com/common_dns_tools/.
I hope you found this explanation on what DNS are and how they work useful. Keep following LinuxHint for more tips and updates on Linux and networking.