# DNS Record Types Explained

---

## **1\. What DNS is**

DNS stands for **<mark>Domain Name System</mark>**. It acts as the "phonebook of the internet," translating human-readable domain names (e.g., [`example.com`](http://example.com)) into machine-readable IP addresses (e.g., `192.0.2.1`) to locate websites.

When you type:

```plaintext
www.example.com
```

Your browser **does NOT know** where that website is.

Computers only understand **IP addresses** like:

```plaintext
93.184.216.34
```

The system of converting that named website into that ip address is what DNS is . It stores the IP adresses required to be visited w.r.t to the names of different websites that is easy for a human to remember.

![High level DNS.png](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fng9va4yjv1n2m3qliri3.png align="left")

## **2\. Why DNS Records Are Needed**

A single domain doesn't just serve one purpose.

A domain needs to answer questions like:

### **1\. Who controls me? (NS Records)**

The **Name Server (NS)** record identifies which server is in charge of your domain's settings. It points to the authoritative server that holds all your other records.

### **2\. Where is my website hosted? (A & AAAA Records)**

These are the basic "rows" in your file:

* **A Records:** Map your domain name to an **IPv4** address (e.g., `192.0.2.1`).
    
* **AAAA Records:** Map it to the newer, longer **IPv6** addresses.
    
* **CNAME Records:** Create an alias, pointing one domain (like [`www.example.com`](http://www.example.com)) to another (like [`example.com`](http://example.com)).
    

### **3\. Where should emails be delivered? (MX Records)**

The **Mail Exchange (MX)** record acts as a routing guide for email. It tells other mail servers which server (like Google Workspace or Outlook) is responsible for accepting your incoming messages.

### **4\. Am I allowed to send emails? (TXT Records: SPF & DKIM)**

These specialized **TXT** records prevent others from spoofing your domain.

* **SPF:** Lists authorized IP addresses allowed to send mail on your behalf.
    
* **DKIM:** Provides a digital "signature" (public key) to prove an email hasn't been tampered with.
    

Each **DNS record solves a specific problem**.

Think of DNS as a **file**, and records as **rows inside it**.

### ***WE WILL SEE EACH OF THESE RECORDS SEPERATELY ONE BY ONE NOW ….***

## 1\. NS Record — “Who is responsible for this domain?”

**Problem it solves:**  
Who has authority to answer DNS questions for this domain?

### Example

```plaintext
example.com → NS → ns1.cloudflare.com
```

Meaning:

> “Cloudflare is responsible for DNS decisions for this domain.”

NS records are there to know who manages the DNS.

## **2\. A Record — *Where is the website? (IPv4)***

### Problem it solves: When someone opens the website, which server IP should be contacted?

Example [example.com](http://example.com) → A → 93.184.216.34

Meaning:

“Go to this IPv4 address to load the website.”

## **3\. AAAA Record — “Where is the website? (IPv6)**

### Same job as A record, newer address format.

Example [example.com](http://example.com) → AAAA → 2606:2800:220:1:248:1893:25c8:1946 Why it exists IPv4 addresses are running out

IPv6 is the future

## **IPv6 V/S IPv4**

### IPv4 has **very few addresses**

IPv4 looks like this:

```plaintext
192.168.1.1
```

That format allows **~4.3 billion** unique addresses.

That sounded huge in the 1980s.  
It is **nothing** today.

## Enter IPv6 — the real fix

### IPv6 address format

```plaintext
2606:2800:220:1:248:1893:25c8:1946
```

Looks scary. Ignore the looks.

### Address capacity

IPv6 gives:

> **340 undecillion addresses**

Translation: **We will never run out again.**

### **Why the internet needs IPv6 (not optional)**

1. Massive address space (main reason)
    
2. Better performance
    
3. Built in modern design
    

## 4\. CNAME Record — “This name is just an alias”

![CNAME](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr5yj0h2zx0taavbtfkc.png align="left")

### What problem it solves

You want multiple names to lead to one real destination without managing IP addresses.

### Simple idea

A CNAME says: “This name is not real on its own. Use another name instead.”

### EXAMPLE 1

```plaintext
www.example.com → CNAME → example.com
```

Meaning:  
[`www.example.com`](http://www.example.com) is just another way to reach [`example.com`](http://example.com).

### **EXAMPLE 2**

The Flow: [`www.example.com`](http://www.example.com) → [`user.github.io`](http://user.github.io)

1. **User Request:** You type [`www.example.com`](http://www.example.com) into your browser.
    
2. **Initial Query:** Your browser asks a **DNS Resolver** (like your ISP or Google DNS) for the address of [`www.example.com`](http://www.example.com).
    
3. **CNAME Discovery:** The resolver finds your domain's [Authoritative Name Server](https://www.cloudflare.com/learning/dns/dns-records/dns-cname-record/), which returns a **CNAME record** saying: "I don't have an IP, but I am an alias for [`user.github.io`](http://user.github.io)."
    
4. **Second Query:** The resolver now starts a **new search** for the address of [`user.github.io`](http://user.github.io).
    
5. **A Record Discovery:** The resolver contacts GitHub’s name servers, which return an **A Record** containing the actual **IP address** (e.g., `185.199.108.153`).
    

**Final Connection:** The resolver gives that IP address to your browser, which then connects to the server and loads the site.

  
**Meaning:**

  
When you enter [`www.example.com`](http://www.example.com), [it redirects t](http://www.example.com/)o [`user.github.io`](http://user.github.io) [through a CNAM](http://user.github.io/)E record, and your browser eventually connects to the correct server using the IP address from the A Record.

###   
**THE DIFFERENCES**

### **1\. A vs CNAME**

A recor[d → domain to I](http://www.example.com/)P address

CNAME [→ domain to an](http://user.github.io/)other domain

A = direct address

CNAME = nickname

### **2\. NS vs MX**

* **NS (The Boss/Phonebook):** It tells the internet, "If you want to know *anything* about this domain, go ask **this** server." It is the master source of truth.
    
* **MX (The Post Office/Mailroom):** It tells the internet, "If you have a **letter** for this domain, deliver it to **this** specific building."
    

---

## 5\. MX Record — “Where should emails go?”

### What problem it solves

When someone sends an email to: [you@example.com](mailto:you@example.com), where should that email be delivered?

**Example:**  
example.com → MX → mail.google.com (priority 10)  
**Meaning:**  
Emails for @example.com should be delivered to Google’s mail servers.

**Key point:**  
MX records are only for email. They have nothing to do with websites.

## 6\. TXT Record — “Extra information & proof”

### What problem it solves

TXT records store instructions and verification data for your domain. They are commonly used for:

* Proving domain ownership
    
* Email security (anti-spam)
    
* Service verification (Google, GitHub, etc.)
    

### Simple idea

A TXT record is: “A text note attached to your domain that machines can read and verify.”

**Example use:**  
Email servers check TXT records to decide if an email is trustworthy.

---

# **Note :**

### This post represents my personal way of understanding DNS Record Types.

Some parts were refined with AI assistance for clarity and structure, while the concepts and explanations reflect my own learning process.
