Understanding DNS and Its Functionality

Aug 10, 2024

Notes on DNS and How It Works

Introduction

  • Host: Piyush
  • Topic: Deep dive into DNS (Domain Name System)
  • Importance: Understanding DNS is crucial for developers, programmers, and cloud engineers.

What is DNS?

  • Full Form: Domain Name System (or Domain Name Server)
  • Function: Translates human-readable domain names (e.g., google.com) into IP addresses.
  • Analogy: Just like you need an address to reach a house, computers need IP addresses to locate servers on the internet.
  • Reason for DNS: Easier to remember domain names than numerical IP addresses.

How DNS Works

  1. User Action: User types a domain name (e.g., google.com) in a browser.
  2. DNS Query: The browser sends a request to a DNS server to resolve the domain name into an IP address.
  3. DNS Resolution Process:
    • The DNS server searches its records for the corresponding IP address.
    • Returns the IP address to the browser, which can then access the website.

DNS Caching

  • Purpose: Reduce latency and load on DNS servers.
  • Levels of Caching:
    • Browser Cache: Stores recently accessed IP addresses.
    • Operating System Cache: Further caching to improve performance.
    • Router Cache: Local network caching.
    • ISP Cache: Internet Service Provider caching.
  • Example: If a user visits a site for the first time, a DNS query occurs. Subsequent visits might not require a new query due to caching.

Handling DNS Load

  • Challenge: A single DNS server cannot handle billions of requests.
  • Solution:
    • Decentralization: Use multiple DNS servers to balance the load.
    • Root Name Servers: 13 hard-coded servers that manage DNS queries.
    • Anycast Routing: Internally route requests to the nearest available server.

DNS Record Types

1. A Record

  • Points a domain to an IPv4 address.

2. AAAA Record

  • Points a domain to an IPv6 address.

3. CNAME Record

  • Allows a domain to point to another domain, effectively creating an alias.
  • Useful for pointing to external services (e.g., Vercel, Google) without worrying about IP changes.

4. MX Record (Mail Exchange)

  • Used for directing email to mail servers.

5. NS Record (Name Server)

  • Specifies which DNS server is authoritative for a domain.

6. TXT Record

  • Used for adding text information related to the domain.

Important Files in DNS Troubleshooting

  • /etc/hosts: Local DNS records for resolving domain names to specific IP addresses.
  • /etc/resolv.conf: DNS settings file indicating which DNS servers to use.

Conclusion

  • Understanding DNS is essential for working in tech fields related to web development, networking, and cloud services.
  • The lecture emphasized the complexity and functionality of DNS, including the various record types and their uses.