DNS Interview Questions

Q) What is DNS?
DNS (Domain Name System) is a service that translates between Internet name and Internet address i.e. it is used to resolve human-readable hostname like google.com into machine-readable IP address

Q) What are DNS records and Types of DNS records?
DNS records are held in zone files used for mapping URL to IP address. DNS records are basically mapping file that tells DNS server which IP address each domain name is associated with, and how to handle requests sent to each domain. These records are typically the connection of your website with the outside world.
Request for your website are forwarded to your DNS server and then get pointed to web server that serves the website or to the Email server that handles the incoming mail.

1. A Record:
A records are one of the key record types within the DNS. The A record is used to associate the domain name to IP address.

2. AAAA Record:
AAAA records are similar to A records. The only difference is that the AAAA records point to the ipv6 address instead of the ipv4 address.

3. CNAME Record:
CNAME stands for Canonical name. A CNAME record points one of your subdomains to a different domain name. i.e. CNAME record is used to define one domain as an alias of another domain.

4. MX Record:
MX record stands for Mail Exchange Record. These records are used to identify the servers that handle the email address for your domain name.

5. NS Record:
NS or Nameserver record maps the domain name to a list of DNS servers authoritative for that domain. NS records indicate authoritative nameserver for the domain.

6. PTR Record:
PTR record type is used to perform the exact opposite functionality of DNS A record type. PTR record is used to translate an IP address to the domain name.

7. SOA Record:
SOA record stands for Start of Authority record. This record is used to inform resolver that the server which contains this record is the authoritative server for the requested domain name. That means it provides authoritative information about the domain.

Q) Recursive query in DNS?
The recursive query is a kind of query in which DNS server who receives your query will do all the job of fetching the answer and giving back to you.
During this process, the DNS server might also query other DNS servers on the internet for your answer.

Step by step understanding
1. Suppose that you want to browse www.example.com and your resolver.conf has got an entry of ISP DNS server.

2. DNS server on receiving the query will look into its table (cache) to find IP address ie A record for example.com.

3. If DNS server does not have the answer for the query in its cache, then it will send this query to “root” DNS server for the answer.

4. The root DNS server will reply with the list of server’s (referral) that are responsible for handling “.com” TLD server.

5. Our DNS server will select one of the .com TLD servers from the list given by root server to query the answer for example.com.

6. Similar to root servers, the TLD servers are also iterative in nature, so it replies back to our DNS server with the list of IP address of DNS servers responsible for the domain (authoritative nameserver) example.com.

7. This time also our DNS server will select one of the IP from given list of authoritative nameserver and queries A record for example.com.

8. Now our DNS server will reply us back with IP domain pair. Now the browser will send the request to the webserver for the content using IP address that it has learned.

9. Our DNS server now stores this record in its table (cache), so next time when it receives the same query then it will serve it from its cache.

Q) Iterative query in DNS?
In an iterative query, the DNS server will not go and fetch the complete answer for your query but will give back referral to another DNS server which might have the answer.

If the DNS server is not recursive (i.e iterative) in nature then, it will give the answer if it has in its record. Otherwise, will give us the referral to root servers, that means it will not query root server and other DNS servers.
Now its job of our resolver to query root servers, TLD servers, and authoritative name servers.
Reference link: Slashroot