Skip to main content

Command Palette

Search for a command to run...

DNS Record Types Explained

Updated
9 min read

How Does a Browser Know Where a Website Lives?

Imagine you want to visit a friend's house, but you only know their name — not their actual street address. You'd probably look them up in your contacts or a phone book to find where they live. The internet works in a remarkably similar way.

When you type www.example.com into your browser, your computer doesn't actually know where that website "lives" on the internet. It needs to look up the actual location, just like you'd look up a friend's address. This is where DNS comes in.

What is DNS? (The Internet's Phone Book)

DNS stands for Domain Name System, but you can think of it simply as the internet's phone book or address directory.

Here's the basic idea: computers and servers on the internet communicate using numbers called IP addresses (like 192.168.1.1). But humans aren't great at remembering long strings of numbers. We're much better with names like google.com or amazon.com.

DNS is the system that translates human-friendly domain names into computer-friendly IP addresses. It's the bridge between what we want (easy-to-remember names) and what computers need (numerical addresses).

The simple flow:

You type: www.example.com
    ↓
DNS translates it to: 93.184.216.34
    ↓
Your browser connects to: 93.184.216.34
    ↓
You see: The website!

Why Do We Need DNS Records?

Think of DNS records as different types of information stored in that internet phone book. Just like a contact card might have someone's home address, work address, email, and phone number, a domain name needs different types of information to work properly.

DNS records tell the internet:

  • Where to find your website

  • Where to send your emails

  • Who's responsible for managing your domain

  • And much more

Without DNS records, domain names would be useless — like having a business card with just a name and no contact information.

DNS Record Types: Your Internet Contact Card

Let's explore the most important types of DNS records. We'll introduce them one at a time, showing what problem each one solves.

1. NS Record (Name Server Record) — Who's in Charge Here?

The problem it solves: When someone asks about your domain, who should they ask for the official information?

Think of NS records as the manager or authority for your domain. They tell the internet, "If you want to know anything about this domain, ask these specific servers."

Real-life comparison: If someone wants to know your work schedule, they should ask your manager, not a random person on the street.

Example:

example.com    NS    ns1.hostingcompany.com
example.com    NS    ns2.hostingcompany.com

This says: "For any information about example.com, check with ns1.hostingcompany.com and ns2.hostingcompany.com — they're the official sources."

You typically have multiple NS records for backup. If one name server is down, the other can still answer questions.


2. A Record (Address Record) — Where Does Your Website Live?

The problem it solves: When someone types your domain into a browser, where should their computer actually connect?

The A record is the most fundamental DNS record. It maps your domain name to an IPv4 address (the current standard for internet addresses).

Real-life comparison: This is like saying "John Smith lives at 123 Main Street." The A record connects a name to a physical location.

Example:

example.com           A    93.184.216.34
www.example.com       A    93.184.216.34
blog.example.com      A    198.51.100.10

Here we're saying:

Notice how you can have different subdomains (www, blog, shop) pointing to different servers, each with their own A record.


3. AAAA Record (IPv6 Address Record) — The Future of Addresses

The problem it solves: The same as an A record, but for the newer IPv6 address system.

As the internet grows, we're running out of IPv4 addresses (there are only about 4 billion possible combinations). IPv6 was created to solve this problem, offering vastly more address possibilities.

Real-life comparison: Like upgrading from a 7-digit phone number to a 10-digit one because we ran out of 7-digit combinations.

Example:

example.com    AAAA    2001:0db8:85a3:0000:0000:8a2e:0370:7334

The address is much longer, but the concept is identical to an A record — it's just the newer addressing system. Most modern websites have both A and AAAA records to support all visitors.


4. CNAME Record (Canonical Name Record) — The Nickname

The problem it solves: What if you want multiple domain names to point to the same place without managing multiple IP addresses?

A CNAME record creates an alias — it makes one domain name point to another domain name, rather than directly to an IP address.

Real-life comparison: If someone asks for "Bob," you might say "Bob is actually Robert Wilson — look him up under that name." You're redirecting them to the canonical (official) name.

Example:

www.example.com       CNAME    example.com
shop.example.com      CNAME    example.com
mobile.example.com    CNAME    example.com

This says: "Don't ask me for the IP address of www.example.com — just look up example.com instead." Then when example.com is looked up, its A record provides the actual IP address.

Important distinction:

  • A record: Points directly to an IP address

  • CNAME record: Points to another domain name (which then has its own A record)

Why use CNAME instead of multiple A records?

If your server's IP address changes, you only need to update one A record instead of five. All the CNAME records automatically follow the change.

Common beginner confusion: You cannot have a CNAME record for your root domain (example.com itself) — only for subdomains like www.example.com or blog.example.com. The root must always have an A record.


5. MX Record (Mail Exchange Record) — Where Should Email Go?

The problem it solves: Email and website hosting are often on different servers. How does an email know where to go?

When someone sends an email to hello@example.com, the MX record tells the sending mail server where to deliver it.

Real-life comparison: Your home address and your PO box might be different. If someone wants to mail you something, you tell them to use the PO box. MX records work the same way for email.

Example:

example.com    MX    10    mail.example.com
example.com    MX    20    backup-mail.example.com

The numbers (10, 20) are priority levels. Lower numbers = higher priority. So email will try mail.example.com first, and if that's unavailable, try backup-mail.example.com.

Common beginner confusion: Your website might be hosted at Company A, but your email might be hosted at Company B (like Google Workspace). That's perfectly fine — the MX record handles that separation.


6. TXT Record (Text Record) — Extra Information and Verification

The problem it solves: Sometimes you need to prove you own a domain or provide additional configuration information.

TXT records hold arbitrary text information. They're incredibly flexible and used for various purposes, most commonly for verification and email security.

Real-life comparison: Like putting a "Verified by..." sticker on your business window to prove authenticity.

Common uses:

Domain verification:

example.com    TXT    "google-site-verification=abc123xyz789"

Google asks you to add this record to prove you control the domain.

Email security (SPF - Sender Policy Framework):

example.com    TXT    "v=spf1 include:_spf.google.com ~all"

This tells email servers which computers are allowed to send email from your domain, helping prevent spam and spoofing.

Email security (DKIM - DomainKeys Identified Mail):

default._domainkey.example.com    TXT    "v=DKIM1; k=rsa; p=MIGfMA0GCS..."

Provides a cryptographic signature to verify your emails are authentic.

TXT records might look confusing at first, but you'll typically just copy-paste them exactly as provided by your email or web hosting provider.


How All DNS Records Work Together

Let's see how these records work together for a real website. Imagine you run a small business called "Example Company" with a domain example.com.

Your complete DNS setup might look like this:

; Name Servers - Who manages this domain
example.com              NS      ns1.cloudprovider.com
example.com              NS      ns2.cloudprovider.com

; Website Records
example.com              A       93.184.216.34
www.example.com          A       93.184.216.34
blog.example.com         A       198.51.100.10

; IPv6 support
example.com              AAAA    2001:db8::1
www.example.com          AAAA    2001:db8::1

; Helpful aliases
shop.example.com         CNAME   example.com
store.example.com        CNAME   example.com

; Email routing
example.com              MX      10    mail.google.com
example.com              MX      20    backup.mail.google.com

; Verification and security
example.com              TXT     "google-site-verification=abc123"
example.com              TXT     "v=spf1 include:_spf.google.com ~all"

What happens when someone visits your website:

  1. User types www.example.com in their browser

  2. Computer asks DNS: "What's the A record for www.example.com?"

  3. DNS responds: "93.184.216.34"

  4. Browser connects to that IP address

  5. Website loads!

What happens when someone sends you an email:

  1. Someone sends email to contact@example.com

  2. Their email server asks DNS: "What's the MX record for example.com?"

  3. DNS responds: "Priority 10: mail.google.com"

  4. Email is delivered to Google's mail servers

  5. You receive it in your Gmail!

What happens when someone visits shop.example.com:

  1. Browser asks: "What's the A record for shop.example.com?"

  2. DNS responds: "That's a CNAME to example.com, look that up instead"

  3. Browser asks: "What's the A record for example.com?"

  4. DNS responds: "93.184.216.34"

  5. Browser connects and website loads!


Visual Summary: Complete DNS Flow

                           ┌─────────────────────┐
                           │   User types URL    │
                           │  www.example.com    │
                           └──────────┬──────────┘
                                      │
                                      ▼
                           ┌─────────────────────┐
                           │   DNS Lookup        │
                           │  "Where is this?"   │
                           └──────────┬──────────┘
                                      │
                   ┌──────────────────┼──────────────────┐
                   │                  │                  │
                   ▼                  ▼                  ▼
         ┌──────────────┐   ┌──────────────┐   ┌──────────────┐
         │  NS Record   │   │   A Record   │   │ CNAME Record │
         │ (Authority)  │   │   (IPv4)     │   │   (Alias)    │
         └──────────────┘   └──────┬───────┘   └──────────────┘
                                   │
                                   ▼
                        ┌────────────────────┐
                        │   IP Address       │
                        │   93.184.216.34    │
                        └──────────┬─────────┘
                                   │
                                   ▼
                        ┌────────────────────┐
                        │   Web Server       │
                        │   Returns Website  │
                        └────────────────────┘


         Email Flow (Separate Path):

         email@example.com
                │
                ▼
         ┌──────────────┐
         │  MX Record   │──────► mail.example.com
         └──────────────┘
                                       │
                                       ▼
                                ┌─────────────┐
                                │ Mail Server │
                                └─────────────┘

Quick Reference Guide

Record TypePurposePoints ToExample
NSAuthority for domainName serversns1.provider.com
AWebsite location (IPv4)IP address93.184.216.34
AAAAWebsite location (IPv6)IPv6 address2001:db8::1
CNAMEAlias/nicknameAnother domainexample.com
MXEmail routingMail servermail.example.com
TXTVerification/infoText data"verification=abc"

Common Questions Answered

Q: Do I need all these record types?
At minimum, you need NS records (your provider sets these), A records (for your website), and if you have email, MX records. The others are optional but useful.

Q: Can I have multiple A records for one domain?
Yes! This is used for load balancing. The DNS system will rotate between them to distribute traffic.

Q: What's the difference between example.com and www.example.com?
They're technically different! example.com is your root domain, and www.example.com is a subdomain. You need separate records for each (though they usually point to the same place).

Q: How long do DNS changes take to work?
Usually 5 minutes to 48 hours. This is called DNS propagation — the time it takes for the change to spread across all DNS servers worldwide.

Q: Can I see my own DNS records?
Yes! Use online tools like "DNS lookup" or "dig" (a command-line tool). Just search for "DNS checker" in your browser.


Final Thoughts

DNS might seem complex at first, but at its heart, it's just a directory system — helping computers find each other using friendly names instead of numbers. Each record type solves a specific problem:

  • NS: Who's in charge?

  • A/AAAA: Where does the website live?

  • CNAME: What are the alternative names?

  • MX: Where does email go?

  • TXT: Proof and configuration

Once you understand what problem each record solves, DNS becomes much less mysterious. You're not expected to memorize everything — even experienced developers look up syntax regularly. What matters is understanding the purpose of each record type and how they work together to make the internet function smoothly.

Welcome to the world of DNS — you now understand one of the internet's most fundamental systems!

7 views