DNS Basics

5/16/2021

DNS removes the need for a users to remember IP address. It is like a phone book, allowing the user to get to a website using its name instead of remembering its IP addresses. Also for the website without static IP address, address may change frequently, which makes it impossible to remember.

Each device connected to the public internet has its own unique IP address assigned to it. DNS uses TCP for zone transfers and UDP for queries. DNS zone tranfer generally involve large responses which require more than one UDP packet if send using UDP. But UDP does not guarantee consistency so TCP is used. Recently DNS over HTTPS was introduced which uses TCP for network requests.

A DNS record contains name, value, TTL, type, class field in it, all of which are mandatory.They are present in the authoritative DNS server. In the name field we store the suffix to the domain name, like blog in case of blog.joel.wiki, for type we store the record type like A, AAAA, MX, and for TTL we store the time to live for that record, in seconds. This value determine how long the recursive DNS server should cache the record.

Types of DNS servers

From the time a client enters a website’s url in browser to getting the IP address to get the data of the website, different servers are involved.

DNS Resolver

This is the first server which receives query from client. If it doesn’t have the IP address cached, it is responsible for making additional queries to other servers(nameserver) to get the IP address of website. Generally you will be using the DNS of the network’s ISP, but you can change it to other public DNS resolvers like Google, Cloudflare.

Root Nameserver

This is the first server in the DNS lookup process, which is initiated when the IP address is not found at the DNS resolver. DNS are structured in heirarchy into different zone where the root servers operate at the root of the hierarchy. A root server should be able to provide results which are cached or provide the address of the TLD nameserver of the TLD domain of the website being queried. You can view the root servers using dig. Currently there are 13 root servers (along with many redundant root servers) from a.root-servers.net to m.root-servers.net.

TLD Nameserver

TLD nameserver maintain authoritative nameserver’s IP address of all domains under that TLD. After getting the authoritative nameserver’s IP address DNS resolver query the authoritative nameserver to get the IP address of domain.

Authoritative Nameserver

Authoritative Nameserver is the last step in resolution of IP address of a domain. Authoritative Nameserver direct source of information about a domain. If authoritative nameserver has access to the requested record, it will return the requested records value back to DNS resolver.

Process Involved In DNS Resolution

  1. User enters a url in the browser’s address bar like - https://joel.wiki/closures-in-python.
  2. If the browser’s DNS cache has the IP address of the website (joel.wiki) and cache is not expired (i.e TTL is not passed), it get IP address from cache.
  3. If there is no valid cache of the website present in the browser, browser querires the DNS cache in Operating System (also host file)
  4. If address for the website is not found in the OS cache we query the DNS resolver.
  5. DNS resolver check’s it’s cache first to see if the IP address is present for the website and the cached value is not expired.
  6. If it is not found. DNS resolver ask the root server. Root server check its cache, if not found, it gives the address of TLD Nameserver for the TLD wiki of the website.
  7. TLD Nameserver check’s its cache to see if the IP address of website is present, if not it will give the authoritative nameserver where we can find the IP address of website. Usually there are more than one authoritative nameservers.
  8. We goto any of the Authoritative Nameserver received and get the IP address of website. There is no cache here. It get the value of the record directly.
  9. At every step the response from each of the nameserver are received by DNS resolver and the DNS resolver send the request to the next server if the information i.e. the IP address of the website is not received.
  10. It is the domain registrar who set the domain and its authoritative nameserver data in the TLD Nameserver.

Types of records

  1. A - Address record. Map server’s IPv4 address to domain name.
  2. AAAA - Address record. Map server’s IPv6 address to domain name.
  3. Alias - Like a CNAME record, alias records can be used to map one address to another. But Aliases can coexist with other records using the same name.
  4. CNAME - Canonical Name record. A CNAME record establishes one domain as an alias to another.
  5. MX - Mail Exchange Record. These records will redirect a domain’s email to the servers hosting the domain’s user accounts.
  6. TXT - used to determine ownership of a domain.
  7. SOA - start of authority record. Store admin information about site.

Conclusion

Being a software developer, DNS was a part knowing which allowed me to have a better picture of how the web works. I hope that you have learned something new from this article.

© 2025 Joel Jacob