What is DNS? Introduction to the Domain Name System
If you have ever dealt with the Internet and computer networks, you probably heard about the domain name system (DNS). After reading the article find out how it all works.
The hostname itself will not give any information about finding the particular machine with which you are going to contact since all connections are by IP addresses.
A domain name server is a device that maps the host name to the IP address of a specific machine / hardware.
This article will cover the details of various DNS queries, types of DNS servers, and variations on DNS records.
These are the computers that providers use to search in their database for a specific node requested by the user. When data is received, the user is redirected to the appropriate IP address. Resolvers play a crucial role in the DNS.
DNS resolver caches information. For example, the site
example.comis located on a machine with an IP address
220.127.116.11. Therefore, resolver caches from all over the world will contain the following correspondence:
It is believed that in the future the site may move to any other host with a different IP, say
18.104.22.168. Caches DNS resolvers around the world for some time will keep the same IP address. This may result in the site being inaccessible until the changes reach all DNS.
The time during which the recording is stored in the resolver is called TTL (time to live).
It can be installed in the service control panel on which the domain was purchased.
Types of DNS servers
Root DNS Server
This is a DNS server that stores the addresses of all TLD servers (TLD – top-level domain). On the way from the hostname to the IP address, the request first goes to the root DNS server.
There are 13 root DNS servers:
This does not mean that there are only 13 machines that process all requests from all over the world – there are also secondary servers to which traffic is distributed.
These servers are linked to top level domains (TLDs). Usually they go after root DNS servers. TLD servers contain information about the top-level domain of a particular host.
Say, if you request the IP address of a host
techy360.com, the TLD server that matches the domain will be polled
.com. The TLD server returns the address of the authoritative DNS server for the resolver.
Now the question arises – how do TLD servers know the address of authoritative servers? The answer is simple – after you buy any domain from a registrar like Godaddy or Namecheap, registrars link authoritative servers to the TLD server.
Now some providers provide the ability to use third-party authoritative servers. You can choose a specific authoritative name server from the registrar.
Authoritative DNS server
The request for these servers comes in the last turn. These servers store actual records of type A, NS, CNAME, TXT, and so on.
Authoritative DNS servers, if possible, return the IP addresses of the hosts. If the server cannot do this, it gives an error and the search for the IP address by servers ends there.
Types of DNS queries
There are 3 types of DNS queries:
- Recursive : similar requests are performed by users to the resolver. Actually, this is the first query that is executed during the DNS lookup. As a resolver, most often is your Internet provider or network administrator.
- Non-recursive : in non-recursive requests, the resolver returns the answer immediately without any additional requests to other name servers. This happens if the necessary IP address is cached in the local DNS server, or if requests are sent directly to authoritative servers, thus avoiding recursive requests.
- Iterative : iterative queries are executed when the resolver cannot return an answer because it is not cached. Therefore, it performs a query to the root DNS server. And he already knows where to find the actual TLD server.
For example, if you are trying to get the IP address of medium.com, then the root domain server will output the TLD server address for
.com. This address will be returned by the root server to the resolver. After that the resolver will poll the TLD server. The TLD server may not know the desired IP address, but it may give the address of the authoritative DNS server for
Let’s try to consider this process in the figure:
Let’s sort the picture above:
- The user makes a request to the resolver to find the IP address. This is a recursive query.
- Resolver, if possible, scans its cache for the required IP address.
- If the resolver has the required IP address, then it returns it.
- Otherwise, the resolver performs an iterative query to the root DNS server. The root DNS server searches for the required TLD for the requested address. For example, if the host is
medium.com, then the TLD is
.com. The root DNS server finds the address of the .com domain and returns a response to the resolver.
- Now the resolver performs an iterative query to the TLD server to get the required IP address. The TLD server returns the address of the authoritative server for the requested host.
- The authoritative server stores the actual host name matching records with the IP address that is returned to the resolver (which, in turn, returns it to the user).
- If the required entry does not exist on the authoritative server, then the error ”
DNS_PROBE_FINISHED_NXDOMAIN” is returned .
- For all servers through which the request passes, the result is cached, and in case of a second request, the result will already be on the server.
- On average, DNS lookups take about 4 queries, but the search will take only a few milliseconds.
What is the result?
Even if you change the record with registrars, making changes on resolvers around the world will take some time. This process can last from 24 to 72 hours, but it usually completes faster, since during this time the TTL-recording at providers has time to expire.