Skip to main content

Command Palette

Search for a command to run...

DNS Record Types Explained: The Internet's Address Book

Published
8 min read

How Does a Browser Know Where a Website Lives?

Imagine you want to visit your friend's house. You know their name, but you need their actual street address to get there. The internet works the same way! When you type example.com into your browser, your computer needs to find the actual location (IP address) of that website's server.

This is where DNS comes in.

What is DNS? (The Internet's Phonebook)

DNS (Domain Name System) is like a massive phonebook for the internet. Just as a phonebook converts names into phone numbers, DNS converts human-friendly domain names (like google.com) into computer-friendly IP addresses (like 172.217.14.206).

Human thinks:     "I want google.com"
                         ↓
DNS translates:   "That's at 172.217.14.206"
                         ↓
Computer connects to that address

Why Do We Need DNS Records?

DNS records are like different types of information in a contact card:

  • Name → What the contact is called

  • Home Address → Where they live

  • Work Address → Where they work

  • Email → How to send them messages

  • Notes → Additional information

Similarly, DNS records store different types of information about a domain. Let's explore each type!


DNS Record Types

1. NS Record (Name Server Record)

"Who is responsible for this domain?"

Think of NS records as the property manager's contact information. They tell the internet which DNS servers are the authoritative source for all information about your domain.

Example:

Domain: example.com
NS Record: ns1.hostingprovider.com
NS Record: ns2.hostingprovider.com

Real-world analogy:
You're looking for information about an apartment building. The NS record tells you which property management company has all the details.

Diagram:

Internet User
     ↓
     asks: "Who manages example.com?"
     ↓
Root DNS Server
     ↓
     answers: "Ask ns1.hostingprovider.com"
     ↓
ns1.hostingprovider.com
     ↓
     "I have all the records for example.com!"

2. A Record (Address Record)

"What is the IPv4 address of this domain?"

An A record is the most common DNS record. It maps a domain name directly to an IPv4 address (the traditional internet address format with four numbers).

Example:

example.com  →  93.184.216.34

Real-world analogy:
Like writing "John's House → 123 Main Street". The name points to the physical address.

Diagram:

Browser: "Where is example.com?"
           ↓
DNS Server checks A Record
           ↓
A Record: example.com → 93.184.216.34
           ↓
Browser: "Got it! Connecting to 93.184.216.34"

3. AAAA Record (IPv6 Address Record)

"What is the IPv6 address of this domain?"

AAAA records do the same job as A records, but for the newer IPv6 addresses (longer addresses with letters and numbers).

Example:

example.com  →  2606:2800:220:1:248:1893:25c8:1946

Why both A and AAAA?
Some devices use the old address system (IPv4), some use the new one (IPv6). Having both ensures everyone can find you!

Real-world analogy:
Like having both a street address and GPS coordinates for your house. Different people use different systems to find you.

Diagram:

Modern Device (IPv6)          Old Device (IPv4)
        ↓                            ↓
    AAAA Record                  A Record
        ↓                            ↓
  2606:2800:...                93.184.216.34
        ↓                            ↓
    Both reach the same website!

4. CNAME Record (Canonical Name Record)

"This name is just another name for something else"

A CNAME creates an alias. Instead of pointing to an IP address, it points to another domain name. The browser then looks up that domain name.

Example:

www.example.com  →  example.com  →  93.184.216.34
blog.example.com →  hosting.blogprovider.com → 104.26.12.45

Real-world analogy:
Your friend goes by a nickname. When someone asks for "Johnny," you say "Oh, you mean Jonathan Smith." They then look up Jonathan Smith's address.

Common confusion: A vs CNAME

  • A Record: Points directly to an IP address (final destination)

  • CNAME: Points to another domain name (which then resolves further)

Diagram:

User wants: blog.example.com
                ↓
         CNAME Record says: "That's actually hosting.blogprovider.com"
                ↓
         Look up hosting.blogprovider.com
                ↓
         A Record: hosting.blogprovider.com → 104.26.12.45
                ↓
         Final destination reached!

Why use CNAME?
If your blog provider changes their IP address, you don't need to update anything. The CNAME still points to their domain, and their A record updates automatically.


5. MX Record (Mail Exchange Record)

"Where should emails for this domain be delivered?"

MX records tell email servers where to send emails for your domain. They include a priority number (lower = higher priority).

Example:

example.com
  MX Priority 10 → mail1.emailprovider.com
  MX Priority 20 → mail2.emailprovider.com

Real-world analogy:
Like having a mail delivery instruction: "Primary mailbox at 123 Main St, if that's full, use the one at 456 Oak Ave."

Common confusion: NS vs MX

  • NS Record: Who manages ALL your domain's DNS records

  • MX Record: Where to send EMAIL specifically

Diagram:

Someone sends email to: user@example.com
            ↓
    DNS lookup for MX records
            ↓
    MX Priority 10: mail1.emailprovider.com
    MX Priority 20: mail2.emailprovider.com
            ↓
    Try mail1 first (lower number = higher priority)
            ↓
    If mail1 is down, try mail2
            ↓
    Email delivered!

6. TXT Record (Text Record)

"Extra information and verification"

TXT records store text information. They're commonly used for:

  • Email verification (proving you own the domain)

  • Security settings (SPF, DKIM for email security)

  • Site verification (proving ownership to Google, etc.)

Example:

example.com  TXT  "v=spf1 include:_spf.google.com ~all"
example.com  TXT  "google-site-verification=abc123xyz"

Real-world analogy:
Like notes on a bulletin board: "This house is verified by the city inspector" or "Mail delivery instructions: no substitutions."

Diagram:

Email server receives email claiming to be from example.com
            ↓
    Checks TXT record (SPF)
            ↓
    TXT: "v=spf1 include:_spf.google.com ~all"
            ↓
    "Is this email coming from Google's servers?"
            ↓
    If YES → Email is legitimate
    If NO  → Email might be spam

How All DNS Records Work Together

Let's see how multiple DNS records work together for a complete website setup:

Complete DNS Setup Example

Domain: myshop.com
Website hosted at: 185.199.108.153
Email hosted at: Google Workspace
CDN for www: Cloudflare

DNS Records Setup:

┌─────────────────────────────────────────────────────────┐
│ myshop.com DNS Records                                  │
├─────────────────────────────────────────────────────────┤
│                                                         │
│ NS Records (Who manages this domain?)                   │
│   ns1.hostingprovider.com                               │
│   ns2.hostingprovider.com                               │
│                                                         │
│ A Record (Main website)                                 │
│   myshop.com → 185.199.108.153                          │
│                                                         │
│ AAAA Record (IPv6 for main site)                        │
│   myshop.com → 2606:50c0:8000::153                      │
│                                                         │
│ CNAME Records (Aliases)                                 │
│   www.myshop.com → myshop.com                           │
│   blog.myshop.com → myblog.hashnode.dev                 │
│                                                         │
│ MX Records (Email routing)                              │
│   Priority 1 → aspmx.l.google.com                       │
│   Priority 5 → alt1.aspmx.l.google.com                  │
│                                                         │
│ TXT Records (Verification & Security)                   │
│   "v=spf1 include:_spf.google.com ~all"                 │
│   "google-site-verification=abc123"                     │
│                                                         │
└─────────────────────────────────────────────────────────┘

Complete Flow Diagram

┌──────────────────────────────────────────────────────────────┐
│                    USER ACTIONS                              │
└──────────────────────────────────────────────────────────────┘
         │                    │                    │
         │                    │                    │
    Visit website      Send email to         Visit blog
    myshop.com         user@myshop.com       blog.myshop.com
         │                    │                    │
         ↓                    ↓                    ↓
┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐
│ DNS Query for   │  │ DNS Query for   │  │ DNS Query for   │
│ myshop.com      │  │ MX record       │  │ blog.myshop.com │
└─────────────────┘  └─────────────────┘  └─────────────────┘
         │                    │                    │
         ↓                    ↓                    ↓
┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐
│ A Record found  │  │ MX Record       │  │ CNAME found     │
│ 185.199.108.153 │  │ Priority 1:     │  │ Points to:      │
│                 │  │ aspmx.l.google  │  │ myblog.hashnode │
└─────────────────┘  └─────────────────┘  └─────────────────┘
         │                    │                    │
         ↓                    ↓                    ↓
┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐
│ Browser connects│  │ Email routed to │  │ DNS resolves    │
│ to website      │  │ Google's mail   │  │ Hashnode's IP   │
│ server          │  │ servers         │  │ address         │
└─────────────────┘  └─────────────────┘  └─────────────────┘
         │                    │                    │
         ↓                    ↓                    ↓
    Website loads        Email delivered      Blog loads

Visual Summary: DNS Record Types at a Glance

┌─────────────────────────────────────────────────────────────┐
│                    DNS RECORD TYPES                         │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  NS (Name Server)                                           │
│  └─► "Who's in charge here?"                                │
│      └─► Points to DNS servers managing this domain         │
│                                                             │
│  A (Address)                                                │
│  └─► "What's the IPv4 address?"                             │
│      └─► domain.com → 93.184.216.34                         │
│                                                             │
│  AAAA (IPv6 Address)                                        │
│  └─► "What's the IPv6 address?"                             │
│      └─► domain.com → 2606:2800:220:1:248:...               │
│                                                             │
│  CNAME (Canonical Name)                                     │
│  └─► "This is an alias for..."                              │
│      └─► www.domain.com → domain.com                         │
│                                                             │
│  MX (Mail Exchange)                                         │
│  └─► "Where does email go?"                                 │
│      └─► Priority 10 → mail.emailprovider.com               │
│                                                             │
│  TXT (Text)                                                 │
│  └─► "Extra information"                                    │
│      └─► Verification, security settings, notes             │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Common Beginner Questions Answered

"Can I use both A and CNAME for the same domain?"

No! A domain can have either an A record OR a CNAME, but not both. Think of it this way: you can't say "my house is at 123 Main Street" and also "my house is actually at John's address" – pick one!

❌ WRONG:
example.com  A      93.184.216.34
example.com  CNAME  other.com

✅ CORRECT:
example.com      A      93.184.216.34
www.example.com  CNAME  example.com

"Why do I need both NS and MX records?"

  • NS records tell everyone which DNS servers manage your domain

  • MX records specifically tell email servers where to deliver your emails

Think of NS as the "building manager" and MX as the "mailroom address" – different jobs!

"How long does it take for DNS changes to work?"

DNS changes can take up to 48 hours to spread across the internet (called "propagation"), but usually work within a few hours. This is because DNS information is cached (temporarily stored) in many places to make the internet faster.


Conclusion

DNS records are the glue that holds the internet together. Each record type serves a specific purpose:

  • NS → Management authority

  • A/AAAA → Direct IP addresses

  • CNAME → Aliases and flexibility

  • MX → Email routing

  • TXT → Verification and security

Together, they ensure that when you type a domain name, you reach the right website, emails get delivered correctly, and everything works securely.

The next time you visit a website, remember: dozens of DNS records worked together in milliseconds to get you there! 🚀