DNS is often called the "Phonebook of the Internet". But unlike a physical phonebook, it is dynamic, distributed, and hierarchical. When you type a URL, your browser doesn't know where to go. It must ask a series of servers to find the answer. This generally happens in less than 50 milliseconds.
The 4 Steps of Resolution
1. Recursive Resolver (Your ISP or 8.8.8.8): The first stop. It checks its cache. If empty, it goes on a journey for you.
2. Root Server (.): There are 13 logical root servers in the world. It doesn't know `google.com`, but it knows who handles `.com`.
3. TLD Server (.com): It knows which Name Server handles `google.com` (e.g., `ns1.google.com`).
4. Authoritative Name Server: The final destination. It knows the exact IP address of `www.google.com`.
1. The Hierarchy (Right to Left)
We read URLs left to right. DNS reads them right to left.
www.example.com. (There is an invisible dot at the end).
- . (Root)
- com (Top Level Domain)
- example (Second Level Domain)
- www (Subdomain)
2. DNS Record Types
| Type | Meaning | Example Value |
|---|---|---|
| A | IPv4 Address | 192.0.2.1 |
| AAAA | IPv6 Address | 2001:db8::1 |
| CNAME | Canonical Name (Alias) | blog.example.com -> example.com |
| MX | Mail Exchange | mail.google.com (For email routing) |
| TXT | Text | Used for verification (SPF, DKIM, Google Site Verify) |
3. Caching & TTL
To prevent overload, DNS answers are cached locally on your computer and router.
Every record has a **TTL (Time To Live)**, usually 300 seconds or 86400 seconds (1 day).
If you change your website's IP, users might not see the change until the TTL expires. This is called "Propagation".