# DNS Records Made Simple: A, AAAA, NS, CNAME, MX, TXT

## Introduction

DNS is a magical system powering the web invisibly. When you enter `youtube.com` in your browser, your browser does not know where to get the data to load up the YouTube website and render it to show you. This is where DNS comes in. It’s a system of multiple different servers around the world that help you find out the IP address associated with a particular domain name.

![Browser querying DNS server and then YouTube server using IP address](https://cdn.hashnode.com/res/hashnode/image/upload/v1769264198037/57cdd49b-9af2-4396-b340-0a86b0512168.png align="center")

However, DNS isn’t just about getting the IP address to load up a website. DNS is much more than that. DNS has this thing called “records”. An IP address is simply one of those records. In this blog post, we are going to take a deep dive into what these DNS records are, why we even need them, and what the different types of records and their use cases are.

* * *

## Pre-Requisites

I assume if you’re reading this blog post, you already know what domains are, why we need them, what DNS is, and how the DNS hierarchy works. If you do not, you can read my previous blog post that covers these exact concepts:

[DNS Resolution Explained: How Websites Reach Your Browser](https://blog.sameerbhagtani.dev/dns-resolution-explained)

* * *

## What are DNS Records?

DNS records, also referred to as entries in DNS zone files, are instructions that live in authoritative DNS servers. These provide different types of information about the domain name, such as:

*   What IP address is associated with this domain?
    
*   Which DNS servers are authoritative for this domain?
    
*   Which mail server(s) receive emails for this domain?
    

* * *

## Why Do We Need DNS Records?

DNS is just a system. It is nothing without DNS records. DNS records hold the actual information about a domain. Imagine listing a product on Amazon, but providing no details about it. This is exactly what DNS would be like without DNS records. Without DNS records, the DNS system would know that a particular domain exists, but wouldn’t know what to do with it.

DNS records are needed because

*   they tell browsers where to go
    
*   they tell email systems where to deliver mail
    
*   they allow aliases and flexibility
    
*   they prove ownership and improve security
    

* * *

## DNS Records

### A Record

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The question it answers: Where should the browser go?</div>
</div>

This is the most fundamental DNS record. The A stands for “Address”, specifically an IPv4 address. An A record maps a domain name to an IPv4 address (e.g.: `142.250.70.78`). This IPv4 address is the address of the server that is hosting the website associated with this domain name. This helps browsers know where to connect and fetch the website data from. Here’s an example:

| **Type** | **Name** | **Content** |
| --- | --- | --- |
| A | example.com | 142.250.70.78 |

### AAAA Record

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The question it answers: Where should the browser go?</div>
</div>

This record is very similar to the `A` record. It answers the exact same question. The difference is that an `A` record maps to an IPv4 address, whereas an `AAAA` record maps to an IPv6 address that looks something like `2001:0db8:85a3:0000:0000:8a2e:0370:7334`. Here’s an example:

| **Type** | **Name** | **Content** |
| --- | --- | --- |
| AAAA | example.com | 2001:0db8:85a3:0000:0000:8a2e:0370:7334 |

### NS Record

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The question it answers: Who is in charge of this domain?</div>
</div>

Remember the authoritative server in the DNS hierarchy? The `NS` record points to that. It tells the internet which name servers are authoritative for this domain. In other words, which name servers hold all the DNS records for this domain. Here’s an example:

| **Type** | **Name** | **Value** |
| --- | --- | --- |
| NS | @ | ns1.example-dns.com |

### CNAME Record

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The question it answers: Which domain is this domain an alias of?</div>
</div>

A CNAME record, which stands for Canonical Name, is quite simple. It helps us create an alias, like a nickname, to another domain. For example, you may create an alias where `www.example.com` points to `example.com`. So whenever someone tries to visit `www.example.com`, it will resolve to `example.com`.

Another use case is when we host a website on a managed hosting service like Vercel, Render, Netlify, etc. and get back a randomized domain name. We can take that domain and create a CNAME record in our DNS settings like this:

| **Type** | **Name** | **Content** |
| --- | --- | --- |
| CNAME | example | 776a4c73a53a8988.vercel-dns-017.com |

### MX Record

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The question it answers: Which mail server(s) receive emails for this domain?</div>
</div>

I am sure you have seen those fancy emails that look like `contact@example.com`. We can create our own email addresses to receive emails based on our domain. And in order to do that, we use the `MX` record. It tells email systems where to deliver emails sent to `contact@example.com`. Here’s an example:

| **Type** | **Name** | **Mail server** |
| --- | --- | --- |
| MX | @ | mail.example.com |

### TXT Record

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">The question it answers: What text-based information is associated with this domain?</div>
</div>

The `TXT` record is used for things like:

*   Domain ownership and verification
    
*   Email security (SPF, DKIM, DMARC)
    
*   Service configuration
    

For example, when you deploy your website on a managed hosting service like Vercel, you usually connect your own domain to it using a `CNAME` record. But here’s the important part: anyone can create a `CNAME` record that points to a Vercel hostname, because that only requires knowing the target domain name.

So if that were the only step, someone could try to take your domain name and point it to their own Vercel project. To prevent this, Vercel needs proof that you actually control the domain you are trying to connect.

This is where `TXT` records come in. Vercel gives you a unique secret verification value and asks you to add it as a `TXT` record in your domain’s DNS settings, like this:

| Type | Name | Content |
| --- | --- | --- |
| TXT | \_vercel | vc-domain-verify=example.com,abc123xyz |

Only the person who has access to the DNS settings of example.com can add this `TXT` record. Vercel then performs a DNS lookup for this `TXT` record. If it finds the exact secret value it generated, it knows that the person connecting the domain really controls it.

* * *

## Putting it All Together

A single website usually uses multiple DNS records at the same time, each solving a different problem. When you visit a website, this is what typically happens:

1.  DNS asks the authoritative servers (defined by `NS` records) for information about the domain.
    
2.  It follows any `CNAME` aliases if they exist.
    
3.  It finally gets an `A` or `AAAA` record containing the server’s IP address.
    
4.  The browser connects to that IP and loads the website.
    
5.  Meanwhile, `MX` and `TXT` records quietly handle email and verification/security tasks in the background.
    

* * *

## Conclusion

DNS records are the building blocks that tell the internet what to do with your domain. Some point your browser to the right server, some handle email, and others prove ownership and add security. Together, they turn a simple domain name into a fully working website and communication system.
