Phase 1: Foundations

DNS resolution, record types & caching behavior

Beginner ~3 min read
Think of it this way A friendly analogy. Read this if the technical version feels dense. Show Hide

When you want to read a cool book, you probably remember its title, like "The Mystery of the Missing Cookie." But if you go to a giant library with millions of books, you can't just shout out the title and expect it to magically appear! The library needs a super organized system to know exactly where that book lives – which aisle, which shelf, and what number it is.

Computers work in a similar way when you type a website name, like youtube.com or kunalganglani.com, into your browser. For us, these names are easy to remember. But computers don't understand names; they need special number codes called IP addresses (like 192.0.2.1). Think of an IP address as the exact shelf number for a website in the huge library of the internet. The job of finding that number for a website name is handled by something called DNS (Domain Name System). It's like the internet's super-smart library system!

When you ask for a website, your computer first checks a small, local library (a bit like your school library) to see if it already knows the shelf number. If not, it asks bigger libraries. It starts with the absolute biggest libraries (called root servers), which know where all the major sections are (like where the .com section is). Then it goes to the .com section library, which knows where to find the specific library that has exactly the book you're looking for (the website's own special library). This journey ensures your computer always finds the correct shelf number, so you connect to the right website.

Just like a library uses different types of cards to describe books, DNS uses different kinds of "records" to store information. An A record is like a standard library card that tells you the regular shelf number for a book. An AAAA record is for a special, super-long shelf number used for newer, bigger books. And a CNAME record is like a note that says, "This book title actually points you to another book, go look for that one instead!" Also, librarians often remember the shelf numbers of really popular books. This is called "caching" – it means they don't have to look up the same popular book every single time someone asks, which makes finding books much faster.

So, when you're building your own cool website or even just setting up a multiplayer game for your friends, understanding DNS means you can make sure everyone's computer knows exactly where to find your awesome project on the internet, quickly and reliably, just like a well-organized library helps everyone find their favorite stories.

When you type a website name like kunalganglani.com into your browser, DNS (Domain Name System) is the service that translates that human-friendly name into a machine-readable IP address (e.g., 192.0.2.1). This translation process is called DNS resolution. Your computer typically starts by asking a local DNS resolver (often provided by your internet service provider). If the resolver doesn't know the answer, it queries a series of servers, starting with root servers, then Top-Level Domain (TLD) servers (like .com), and finally the authoritative name server that holds the definitive information for kunalganglani.com. This journey ensures you always get the correct IP to connect to the intended service.

DNS stores this information in various record types, each serving a specific purpose. For SREs, the most common and crucial types are: A records (maps a hostname to an IPv4 address), AAAA records (for IPv6 addresses), and CNAME records (creates an alias, mapping one hostname to another hostname, like www.example.com pointing to example.com). Other important types include MX (mail exchange, for email servers), NS (name server, indicating which servers are authoritative for a domain), and TXT (text records, often used for verification or policy information like SPF).

To make DNS queries faster and reduce the load on authoritative servers, DNS information is extensively cached at various points: your local computer, your router, your ISP's resolver, and intermediate DNS servers. Each DNS record has a TTL (Time To Live) value, specified in seconds, which dictates how long a resolver can store and serve a cached copy of that record before it must query the authoritative server again. A higher TTL means faster subsequent lookups but slower propagation of any changes you make to your DNS records. Conversely, a lower TTL ensures changes propagate quickly but might lead to more frequent queries on authoritative servers. Understanding TTL is critical for managing DNS changes and troubleshooting connectivity issues.

Key Takeaways

  • DNS translates human-readable domain names into IP addresses for computers.
  • Common record types like A, AAAA, and CNAME are essential for directing web traffic.
  • DNS resolution involves a hierarchical query process from local resolvers to authoritative servers.
  • Caching speeds up DNS lookups, and TTL (Time To Live) dictates how long records are cached.
  • Adjusting TTL values impacts the speed of DNS propagation and server query load.

Code Example

bash
dig kunalganglani.com A

# Expected output (simplified):
; <<>> DiG 9.10.6 <<>> kunalganglani.com A
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3672
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;kunalganglani.com.             IN      A

;; ANSWER SECTION:
kunalganglani.com.      300     IN      A       104.21.23.141

;; Query time: 10 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Jan 01 12:00:00 PST 2023
;; MSG SIZE  rcvd: 64

How this code works

This dig command demonstrates how to perform a DNS lookup, a fundamental step in understanding DNS resolution. It queries a DNS server to find the IP address associated with a domain name. Specifically, dig kunalganglani.com A asks for the A record (which stands for Address) for the domain kunalganglani.com. The A record always points to an IPv4 address, allowing web browsers and other clients to connect to the correct server. The output shows the request being sent to SERVER: 8.8.8.8#53, which is Google's public DNS resolver, illustrating how dig defaults to a known recursive resolver if not explicitly told otherwise.

The ANSWER SECTION is the core of the response, providing the resolved information. Here, kunalganglani.com. 300 IN A 104.21.23.141 confirms that the domain resolves to the IPv4 address 104.21.23.141. A subtle but critical detail for beginners is the 300 value. This is the Time To Live (TTL) in seconds, indicating how long a DNS resolver, like a browser or local operating system, can cache this record before needing to query the DNS server again. A higher TTL means fewer queries but slower propagation of changes, directly impacting caching behavior and how quickly SREs can update domain-to-IP mappings.