Back to Blog

How DNS Works

How DNS Works
Command of the Day
dig +trace yourdomain.com

What it does: Traces the complete hierarchical DNS resolution chain from Root servers down to Authoritative nameservers in real time.

Every time you open a browser and type rivincloud.in, your computer performs a series of lightning-fast network requests behind the scenes to convert that human-friendly name into a numeric IP address (192.0.2.1). This distributed, global system is called the Domain Name System (DNS).

In this guide, we break down how DNS resolution works step-by-step from browser click to server response.


1. The 4 Key Players in DNS Resolution

To find an IP address, four distinct types of DNS servers collaborate:

Browser ──> 1. Recursive Resolver ──> 2. Root Nameserver (.)
                   │                      │
                   ├──> 3. TLD Nameserver (.in / .com)
                   │                      │
                   └──> 4. Authoritative Nameserver (ns1.rivincloud.in) ──> Returns IP!
  1. DNS Recursive Resolver (Recursive Server): The middleman between your computer and the Internet (typically provided by your ISP or public services like 1.1.1.1 or 8.8.8.8).
  2. Root Nameservers (.): 13 global root server clusters managed by IANA/ICANN that direct resolvers to Top-Level Domain (TLD) servers.
  3. TLD Nameservers: Servers responsible for managing specific domain extensions like .com, .org, .in, or .net.
  4. Authoritative Nameservers: The final authority (such as Cloudflare or your registrar) holding the actual A records and zone configuration for your specific domain.

2. The 8 Steps of a DNS Lookup

When you request https://example.com for the first time:

  1. Local Cache Check: Your browser checks its internal DNS cache, followed by your operating system cache (/etc/hosts or Windows DNS cache).
  2. Recursive Query: If not cached, your OS queries your configured Recursive DNS Resolver.
  3. Querying the Root: The resolver queries one of the Root Nameservers (.).
  4. Root Referral: The Root server responds with the IP of the TLD Nameserver for .com.
  5. Querying the TLD: The resolver queries the .com TLD server for example.com.
  6. TLD Referral: The TLD server responds with the Authoritative Nameservers for example.com (e.g., ns1.rivincloud.in).
  7. Querying Authoritative Server: The resolver asks ns1.rivincloud.in for the A record of example.com.
  8. Final IP Returned: The authoritative nameserver returns 192.0.2.50. The resolver caches this answer based on the TTL and returns it to your browser, which initiates the TCP handshake!

3. Tracing a DNS Lookup Live in Linux

You can watch this exact 4-step hierarchy execute in real time using dig +trace:

dig +trace rivincloud.in

Example Trace Output:

  • Phase 1: Fetches Root hints from a.root-servers.net.
  • Phase 2: Queries .in TLD nameservers (in.cctld.in).
  • Phase 3: Queries authoritative nameservers for rivincloud.in.
  • Phase 4: Obtains the final A record answer.

4. DNS Caching & TTL (Time To Live)

DNS would overwhelm the global Internet if every request traversed the entire root chain. Caching prevents this:

  • Browser Cache: Caches IP lookups for a few minutes.
  • OS Cache: Caches records locally for the system.
  • Resolver Cache: ISP resolvers store the record for the exact duration defined by the zone's TTL (Time to Live) value in seconds.

Common Mistakes

  • Lowering TTL after making DNS changes: Always lower TTL to 300 seconds a few days before a scheduled server migration, so resolvers don't hold outdated caches.
  • Overlooking Recursive DNS Outages: If your server cannot connect to package mirrors, check if /etc/resolv.conf has valid resolvers (e.g., nameserver 1.1.1.1).

Troubleshooting

  • Flushing Linux DNS cache (systemd-resolved):
    sudo systemd-resolve --flush-caches
    # Or on newer distributions:
    sudo resolvectl flush-caches
    

Best Practices

  • Use Anycast DNS providers (like Cloudflare or Route 53) to ensure low-latency DNS resolution for global users.
  • Implement DNSSEC (Domain Name System Security Extensions) to protect your domain against DNS spoofing and cache poisoning.

Frequently Asked Questions

Why does DNS propagation take up to 24-48 hours?

Different ISP resolvers and proxy caches across the globe respect different caching rules and maximum TTL ceilings before discarding old DNS responses.


Conclusion

DNS is the bedrock of Internet connectivity. Understanding the resolution flow from root to authoritative server empowers you to debug domain routing and latency on your RivinCloud VPS!