> For the complete documentation index, see [llms.txt](https://notes.mikaelsamvelian.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.mikaelsamvelian.com/linux-fundamentals/networking/dns-domain-name-system.md).

# DNS (Domain Name System)

### **What is DNS?**

The Domain Name System (DNS) is a decentralized naming system for devices and services connected to the internet or private networks. It translates human-friendly domain names (like google.com) into machine-friendly IP addresses (such as 192.168.0.1). This allows browsers to locate and load resources on the internet without needing to memorize numerical IP addresses.

### **What layer of the OSI model does it operate at?**

**DNS (Domain Name System)** operates at the **Application Layer** (Layer 7) of the OSI model.

### **How Does DNS Work?**

DNS resolves human-readable domain names into IP addresses. This process involves four main components:

1. **DNS Recursor**: A server acting as a "librarian" that receives queries from browsers and initiates additional requests to fulfill the DNS query.
2. **Root Nameserver**: The first step in finding an IP address, similar to a library index, directing the query to more specific servers.
3. **TLD Nameserver**: Points to servers associated with the top-level domain (like .com or .net).
4. **Authoritative Nameserver**: The final stop that stores the actual IP address for the requested domain.

### **DNS Lookup Steps:**

<figure><img src="/files/QueGXmUbIe65cDCgD8Jo" alt=""><figcaption><p><a href="https://www.iotforall.com/a-simple-explanation-of-the-domain-name-system">https://www.iotforall.com/a-simple-explanation-of-the-domain-name-system</a></p></figcaption></figure>

1. A user types in a domain like "example.com."
2. The browser queries a **DNS resolver**.
3. The recursor asks the **root nameserver**, which points to the relevant **TLD server**.
4. The **TLD server** provides the IP address of the domain’s nameserver.
5. The recursor gets the IP address from the authoritative nameserver and returns it to the browser.

The browser can now load the web page by sending a request to that IP.

Here's another image showing the step by step process:

<figure><img src="/files/7QQmaUfePMZoeMecDXfA" alt=""><figcaption><p><a href="https://bluecatnetworks.com/glossary/what-is-a-dns-server/">https://bluecatnetworks.com/glossary/what-is-a-dns-server/</a></p></figcaption></figure>

### **Types of DNS Queries:**

1. **Recursive Query**: The DNS client expects a definitive answer (either the record or an error).
2. **Iterative Query**: The DNS server returns the best possible answer or a referral to another server.
3. **Non-Recursive Query**: This occurs when the DNS resolver already has the information cached and returns it without needing further queries.

### **DNS Caching:**

To speed up the process, DNS records are cached in various locations:

* **Browser Cache**: Modern browsers store DNS records locally for a short time.
* **Operating System Cache**: The OS also caches DNS records to avoid repetitive queries.
* **ISP Caching**: ISPs store frequently requested DNS records to reduce query time further.

In some cases, Cloudflare DNS optimizes this process with infrastructure designed to handle high traffic, such as root DNS servers.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.mikaelsamvelian.com/linux-fundamentals/networking/dns-domain-name-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
