It is well known that different websites have different names. These are called domain names. But devices don’t understand names, they know only IP addresses. Conversely remembering a list of IP addresses will be very cumbersome for humans. Therefore, when we enter a domain name, we need a process where this domain name can be converted to its respective IP address. This task of converting domain names to IP addresses and vice versa is accomplished by the Domain Name System protocol.
Domain names must be registered with ICANN (Internet Corporation for Assigned Names and Numbers), usually through an intermediary such as VeriSign or GoDaddy. Top Level Domains or TLDs include .com, .edu, .org, and others that we typically see at the end of a Fully Qualified Domain Name (FQDN). DNS works hierarchically. The Top Level Domains or TLDs can have multiple subdomains under them.
Background to understand the working of DNS
Initially when the Internet was small i.e. there were very few websites the mapping of domain names to IP addresses could be done in a single text file called the Host File which was stored locally in each device.
But now the Internet consists of billions of IP addresses, therefore the host file itself does not suffice.
There is a domain name mapped against each IP address, each mapping is called the DNS record. The file containing all the DNS resource records is called the zone file.
As the Internet is huge, maintaining a centralized record is almost impossible. Therefore, these records are further divided into smaller DNS namespaces known as the DNS zones, which are maintained and managed by organizations.
The user will first query a DNS record (say google.com) following which the DNS resolver in the system will look for the DNS entry to fetch the IP address from the local cache of the system. If it is not there, it will query the DNS server provided by the Internet Service Provider (ISP).
DNS works on the principle of distributing responsibilities to various nameservers, which plays a key role in resolving domain names. They are: –
Root nameserver: It responds to DNS queries received from the DNS resolvers and sends them back to the DNS resolver. The job of root nameservers is not to resolve domain names but instead to respond with a list of authoritative nameservers corresponding to the top-level domain nameservers connected to the root nameservers. Once it receives the IP address, it responds to the DNS resolver. There is a total of 13 root nameservers present in the world.
Top-level domain nameserver: This is the second topmost level of the domain server, which keeps the records of all website suffixes such as .com, .edu, .in, and .org. Once a request is received from the root nameserver, it checks for the suffix and passes the request in search of the domain name entry to the respective authoritative nameservers. Once it receives the response from the authoritative nameserver, it sends the request back to the root nameserver.
Authoritative nameserver: This is the final stop for all the DNS queries, as it contains the IP address of the domain name. All the DNS records are stored with the authoritative nameserver or the connected multiple nameservers if the IP address for the requested domain is not present in its cache. Once it receives the IP address, it sends the request back to the top-level nameservers.
Working Of DNS
1. The DNS request starts when a user types the domain (test.xyz.in) in the address bar of the browser.
2. The DNS resolver will first check for the DNS entry in the local DNS cache. If it doesn’t find it in the local DNS cache, it forwards the request to the ISP.
3. Once the ISP receives the requests, it checks the DNS query for the domain entry in its cache, and if it is not present there, it sends the request to the root nameserver.
4. Once the root nameserver receives the DNS query, it checks and sends the request to the top-level domain nameserver.
5. Once the top-level domain nameserver receives the DNS request, it checks the suffix (in this instance, .in) and sends it to the respective Indian authoritative nameserver.
6. Once the respective authoritative nameserver receives the DNS query, it checks in its local DNS cache server, and if the DNS entry is not present there, it sends queries to multiple other connected authoritative nameservers to check for the corresponding DNS entry. Once the DNS entry is received say by the m-authoritative nameserver, it sends queries to the original authoritative nameserver, which then sends the IP address to the top-level domain nameserver and then back to the root nameserver.
7. Once the DNS resolver receives the IP address, it creates a DNS entry in the local DNS cache, so if the same DNS is requested again, the DNS resolver will automatically load up with the IP address and the web page will quickly open.
This whole process is called a DNS recursive search.
DNS Records
Also known as zone files are instructions that are present in authoritative name servers. Their job is to provide information about a domain. Various files associated with it provide various information. Some of them are: –
A Record (Address): Provides IPv4 address for the respective domain name.
AAAA Record: Provides IPv6 address.
CNAME (Canonical Name): Redirects DNS queries to that hostname instead.
NS Record (Name Server): Authoritative nameserver. Contain other DNS records.
MX Record (Mail Exchange): Tells where to send email.
CAA Record: Certificate authority rules.
SOA Record (Start Of Authority): Stores admin information about the domain.
TXT Record (Text): This lets the owner of a domain store the value in DNS and it is used for domain ownership verification.
PTR Record (Pointer): Reverse of A record. It provides the domain name for its respective IP address.
The Domain Name System or DNS is one of those network protocols that make the world go round. Without it, we would need to remember innumerable IP addresses just to navigate to our favourite websites. Hence, we can now access websites on the internet without knowing their IP address thanks to DNS.