Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Updated
3 min read

when you type google.com in your browser, computer doesn’t understand what is it.

It only understand numbers(IP address).

Analogy : When you type “father” in Phonebook. It translate father to “8789******” .

  • Phonebook do for your phone.

  • DNS do the same for your browser. It translates domain name(google.com) to IP address(142.251.43.110).

www.google.com -----> IP address (142.251.43.110)

What is DNS and Why name resolution exist

DNS(Domain Name Server) is the phonebook of the internet. Human access information online through domain names like google.com, cloudflare.com, chaicode.com, etc. Web browser interact through Internet protocol address(IP address).

  • DNS resolution which translates domain name into IP address.

DNS Hierarchy

Understanding the DNS System Hierarchy: How the Internet Finds Your Website

DNS layers happens in layers:

  • Root Domain: Root servers know where is TLD(.com, .net, .in).

  • TLD Server: TLD knows who manages .com domain.

  • Authoritative Server: These servers are the source of truth for google.com


What is dig command ?

dig stands for Domain Information Groper.

dig is command line tools which used for:

  • Query DNS records

  • Debug DNS issues

  • understand how DNS resolutions work

  • checking authoritative name servers

1. dig . NS —> Root Name Servers

command:

dig . NS // you ask, who are the name server for root DNS

Result:

a.root-servers.net
b.root-servers.net
...
m.root-servers.net
  • Root servers don’t know the IP addreses

  • Root servers know where is TLD(.com, .net, .in)

2. dig com NS —> TLD Name Servers

command:

dig com NS  // you are asking, which server manages .com domain

Result:

a.gtld-servers.net
b.gtld-servers.net
...
  • They are TLD(Top Level Domain)

  • TLD don’t know where the IP address is

  • TLD knows who manages google.com

3. dig google.com NS —> Authoritative Name Servers

command:

dig google.com NS  // Now, you are saking Which DNS servers are authoritative for google.com

Result:

ns1.google.com
ns2.google.com
ns3.google.com
ns4.google.com
  • These servers are the source of truth for google.com .

Authoritative Name Servers stores the real DNS:
→ A record (IP)

→ MX record (mail)

→ TXT record (verification)


dig google.com —> DNS Resolution Flow

command:

dig google.com

Result:

google.com.   300   IN   A   142.250.190.14

142.250.194.14 : This is the IP address of google.com


Full DNS Resolution Flow

Connecting the dots : Browser —> Recursive Resolver —> Root Server —> TLD —> Authoratative Server

Example: Browser —> google.com

Step 1: Browser ask Recursive Resolver, Whats is google.com

Step 2: Resolver asks Root, Root says: Ask .com servers

Step3: Resolver asks TLD (.com), .com says: Ask google.com servers

Step 4: Resolver asks Authoritative server, google server responds.

Step 5: Resolvergets IP address, 142.250.190.14

Step 6: Finally, Browser connects

Recursive Resolver Behind the Scene

Our browser never talk to root server or TLD.

  • Middleman between client and the other DNS

  • Perform all the lookup on your behalf

  • Handles retry and failures

  • Caches results to improve speed


Conclusion

DNS is one of the most fundamental systems of the internet.It acts like a phonebook that maps, Domain names → IP addresses. The dig command helps us inspect DNS resolution layer-by-layer:

  • dig . NS : Root servers

  • dig com NS : TLD servers

  • dig google.com NS : Authoritative servers

  • dig google.com : Final IP resolution