Skip to main content

Command Palette

Search for a command to run...

A Simple Guide to How DNS Resolution Works

Published
2 min read

What is DNS?

In simple terms, DNS is the phonebook of Internet. When we type hashnode.com into our browser, our computer magically shows us the website of hashnode, as if it knows where the hashnode Server lives on the Internet.

Computer communicates using IP addresses, not names. DNS help In finding the IP address using domain names.
Without DNS, we would have to remember IP address of every website that we visit.

Why Name Resolution Exist?

Name resolution fix are three big problems

  1. Human friendly names.

    Names are easy to remember than numbers.

  2. IP address can change.

    The server of a website changes sometimes scale globally or use load balancer. DNS lets this happen without Users notice.

  3. Scalability

    A single system cannot store all Internet names that’s why DNS is distributed.

Introducing DIG: A DNS Diagnostic Tool

DIG or Domain Information Groper is a command line tool, which is used To inspect DNS resolution.

It reveals

  • Who answered DNS queries

  • Which servers are responsible

  • Helps debug DNS issues

DNS Resolutions Layers

DNS resolution is not a single step process.

It happens in layers

Let’s walk through each layer using dig.

  1. dig . NS - Root Name server

Here

  • . Represent the DNS root

  • NS means Name server

This command shows the root name server of the internet

  • They don’t know IP address of the websites

  • They only know where to find the TLD servers like .com or .org

Think it like

“I don’t know hashnode.com but i know who manages .com

dig com NS - TLD Name Servers

  1. It asks who manages .com domains?

    This returns TLD name server for .com

    • These servers don’t know hashnode.com IP either

    • They know who servers manage hashnode.com

Think it like

“I don’t the IP but I know who manages hashnode.com

dig hashnode.com NS - Authoritative Name Servers

  1. It asks who is authoritative for hashnode.com

    This returns Google’s authoritative name servers.

    • These servers hold the actual DNS records

    • They are final authority for domain

  2. dig hashnode.com - Full DNS Resolution

    What happens BTS

    A recursive resolver(your ISP, browser, or public DNS like 8.8.8.8):

    a. Starts at the root

    b. Goes to the .com TLD

    c. reaches hashnode’s authoritative servers

    d. Gets the IP address

    e. caches the result for future use

    What we see

    a. A record (IPv4)

    b. Possibly AAAA record (IPv6)

Closing Statement

DNS is distributed not centralized. Understanding it helps in

  • Debugging production issues

  • Understanding latency and failures