Skip to content
Shubham JangleResources
Networking

Explore topics

DNS

DNS

  • There are millions of servers around the world, but when you type chatgpt.com into your browser, how does it know which server to connect to?
  • That is where DNS (Domain Name System) comes in.
  • Think of DNS as the internet's contacts app:
    • A contacts app maps names to phone numbers.
    • DNS maps domain names to IP addresses.

Example: pointing a domain to a website

  • Suppose you buy desisubtitles.com from GoDaddy or Porkbun and host your website on Vercel.
  • In your domain's DNS settings, you add an A record pointing to the IPv4 address of your Vercel server.
  • When someone enters desisubtitles.com, the browser starts a DNS lookup using a DNS resolver, such as Google or Cloudflare.

How a DNS resolver works

  • The DNS resolver asks a Root DNS Server for the .com nameservers.
  • The .com nameservers are managed by Verisign and direct the resolver to the authoritative nameservers for your domain.
  • The resolver asks the authoritative nameserver for the A record containing your server's IP address.
  • The resolver returns that IP address to the browser, and the browser connects to the server.

DNS caching and TTL

  • Imagine migrating your website from Vercel to EC2:
    • Your EC2 instance has a new IP address.
    • You update the A record in your DNS settings.
    • Some users may still connect to the old IP address.
  • This happens because of DNS caching.
    • DNS resolvers temporarily cache responses, so they do not need to repeat the full DNS lookup for every request.
    • Every DNS record has a TTL (Time To Live), which specifies how long the record can be cached.
    • Once the cached record expires, the resolver can fetch the updated IP address.

Summary

  • DNS translates domain names into IP addresses using resolvers, Root DNS Servers, and authoritative nameservers.
  • DNS resolvers return IP addresses, while caching and TTL control how long those answers can be reused.