DNS Record Types Explained: The Complete Beginner's Guide
Understand NS, A, AAAA, CNAME, MX, and TXT records. Learn how DNS works as the phonebook of the internet with simple analogies and real examples.

BCA student and developer who loves learning in public. I build web and mobile projects, explore databases and backend systems, and document my journey through blogs. Currently focused on writing clean code and growing one commit at a time.
DNS Record Types Explained: The Complete Beginner's Guide
Ever wonder how your browser actually finds a website? You type in google.com, hit enter, and boom—you’re looking at Google. But how does your computer know where to go, out of all the billions of devices online?
That’s DNS at work. And if you want to get serious about web development, you’ve gotta know how it ticks.
Introduction
Imagine you want to visit a friend's house. You know their name, but you need their address to actually get there. You'd look them up in a phone book or contact list, right?
DNS (Domain Name System) works exactly like this for the internet. It's the phonebook of the internet — translating human-friendly names like google.com into computer-friendly addresses like 142.250.193.206.
But DNS doesn't just store one type of information. It stores different record types, each solving a specific problem. Let's explore them one by one.
Prerequisites
Basic understanding of what a website is
Familiarity with browsers and web addresses
What is DNS?
Let's start simple. Every device connected to the internet has a unique address called an IP address. It looks something like this:
IPv4:
192.168.1.1(the older format)IPv6:
2001:0db8:85a3:0000:0000:8a2e:0370:7334(the newer format)
Now imagine having to remember 142.250.193.206 every time you want to visit Google. That's impossible for humans!
DNS solves this problem. It lets you type google.com and automatically finds the right IP address for you.
You type: google.com
DNS returns: 142.250.193.206
Browser connects to: 142.250.193.206
You see: Google's homepage
💡 Think of it this way: DNS is like your phone's contact list. You tap "Mom" instead of dialing 555-123-4567. DNS translates "google.com" into its actual address.
Why Do We Need DNS Records?
A website needs more than just "where it lives." Consider these questions:
Where should emails for
yoursite.comgo?Who is responsible for managing this domain?
Does
www.yoursite.compoint to the same place asyoursite.com?How can we verify we own this domain?
DNS records are different types of entries that answer these questions. Each record type stores specific information about your domain.
Think of your domain like a house:
Address → Where the house is located (A Record)
Mailbox → Where mail gets delivered (MX Record)
Property deed → Who owns/manages it (NS Record)
Nickname → "The Smith House" → 123 Main St (CNAME Record)
Notice on door → Extra information for visitors (TXT Record)
Let's explore each record type in detail.
NS Record: Who's in Charge?
NS stands for Name Server.
What Problem Does It Solve?
When someone looks up your domain, how does the internet know which server has all your DNS information? The NS record answers: "Go ask this server — they have all the records for this domain."
Real-Life Analogy
Imagine you call a company's main phone line and ask for John from Accounting. The receptionist says, "Let me transfer you to the Accounting department — they'll help you find John."
The NS record is like that receptionist, directing queries to the right department (nameserver).
What It Looks Like
example.com. NS ns1.hostingprovider.com.
example.com. NS ns2.hostingprovider.com.
This says: "If you want DNS information about example.com, ask ns1.hostingprovider.com or ns2.hostingprovider.com."
ℹ️ Note: Most domains have at least 2 NS records for redundancy. If one nameserver is down, the other can still respond.
When You'll See It
When you buy a domain, you set NS records to point to your hosting provider
When you migrate hosting, you update NS records to point to the new provider
A Record: The Main Address
A stands for Address (specifically IPv4 address).
What Problem Does It Solve?
This is the most fundamental DNS record. It answers the question: "What is the IP address of this domain?"
Real-Life Analogy
The A record is your house's street address. When someone asks, "Where does John live?", you give them "123 Main Street." The A record gives computers the exact "street address" (IP) of your server.
What It Looks Like
example.com. A 192.0.2.1
www.example.com. A 192.0.2.1
blog.example.com. A 192.0.2.50
This says:
example.comlives at192.0.2.1www.example.comalso lives at192.0.2.1blog.example.comlives at a different address:192.0.2.50
Multiple A Records
You can have multiple A records for the same domain (for load balancing):
example.com. A 192.0.2.1
example.com. A 192.0.2.2
example.com. A 192.0.2.3
DNS will rotate between these addresses, distributing traffic across servers.
💡 Tip: The A record is usually the first record you set up when launching a website.
AAAA Record: The Modern Address
AAAA (pronounced "quad-A") is like the A record, but for IPv6 addresses.
What Problem Does It Solve?
We're running out of IPv4 addresses! There are only about 4.3 billion possible IPv4 addresses, but the internet has way more devices. IPv6 solves this with a much larger address space.
The AAAA record answers: "What is the IPv6 address of this domain?"
Real-Life Analogy
Think of IPv4 as old 7-digit phone numbers and IPv6 as new phone numbers with area codes and country codes. The AAAA record stores the "new, longer format" address.
What It Looks Like
example.com. AAAA 2001:0db8:85a3:0000:0000:8a2e:0370:7334
A vs AAAA: What's the Difference?
| Feature | A Record | AAAA Record |
| IP Version | IPv4 | IPv6 |
| Address Format | 192.0.2.1 | 2001:db8:85a3::8a2e:370:7334 |
| Address Length | 32 bits | 128 bits |
| Example | 142.250.193.206 | 2607:f8b0:4004:800::200e |
ℹ️ Note: Many websites have both A and AAAA records. Modern browsers prefer IPv6 when available.
CNAME Record: The Nickname
CNAME stands for Canonical Name (think: "the real name").
What Problem Does It Solve?
Sometimes you want multiple domain names to point to the same place without duplicating A records everywhere. CNAME lets one domain name point to another domain name.
Real-Life Analogy
Imagine your friend John also goes by "Johnny" and "J-Man." All three names refer to the same person. You could say:
"Johnny" → points to "John"
"J-Man" → points to "John"
"John" → lives at 123 Main St
CNAME works the same way — it's an alias that points to the "real" name.
What It Looks Like
www.example.com. CNAME example.com.
blog.example.com. CNAME example.com.
shop.example.com. CNAME myshopify.com.
This means:
www.example.comis a nickname forexample.comblog.example.comis a nickname forexample.comshop.example.compoints to Shopify's servers
A Record vs CNAME: When to Use Which?
| Use Case | Record Type | Example |
Root domain (example.com) | A Record | example.com → 192.0.2.1 |
| Subdomain pointing to IP | A Record | api.example.com → 192.0.2.5 |
| Subdomain pointing to another domain | CNAME | www.example.com → example.com |
| Third-party services | CNAME | shop.example.com → shops.myshopify.com |
⚠️ Warning: You cannot use a CNAME for the root domain (
example.com). CNAMEs only work for subdomains. The root domain must use an A record.
MX Record: Where's the Mailbox?
MX stands for Mail Exchange.
What Problem Does It Solve?
When someone sends an email to john@example.com, how does their email server know where to deliver it? The MX record answers: "Send emails for this domain to this mail server."
Real-Life Analogy
Think of the MX record as the "mailbox location" for your domain. Your house (website) might be at 123 Main St, but your mailbox could be at the community mailroom at 100 Main St. They're different locations for different purposes.
What It Looks Like
example.com. MX 10 mail.example.com.
example.com. MX 20 backup-mail.example.com.
Notice the numbers (10, 20)? That's the priority. Lower numbers = higher priority.
First, try
mail.example.com(priority 10)If that fails, try
backup-mail.example.com(priority 20)
Using Email Services
If you use Gmail for business or Microsoft 365, your MX records point to their servers:
# Google Workspace
example.com. MX 1 aspmx.l.google.com.
example.com. MX 5 alt1.aspmx.l.google.com.
# Microsoft 365
example.com. MX 0 example-com.mail.protection.outlook.com.
NS vs MX: What's the Difference?
| Record | Purpose | Handles |
| NS | Who manages DNS for this domain? | DNS queries |
| MX | Where should emails go? | Email delivery |
They sound similar but serve completely different purposes!
TXT Record: The Sticky Note
TXT stands for Text.
What Problem Does It Solve?
Sometimes you need to attach extra information to your domain that doesn't fit other record types. TXT records store arbitrary text data for various purposes.
Real-Life Analogy
Think of TXT records as sticky notes on your front door. They contain messages or information for specific visitors:
"Delivery drivers: leave packages at the back door"
"This house is owned by John Smith"
What It Looks Like
example.com. TXT "v=spf1 include:_spf.google.com ~all"
example.com. TXT "google-site-verification=abc123xyz"
Common Uses
1. Domain Verification
When you add your domain to Google Search Console, GitHub Pages, or other services, they ask you to add a TXT record to prove you own the domain.
example.com. TXT "google-site-verification=abc123xyz789"
2. Email Security (SPF)
Tells email servers which servers are allowed to send emails on behalf of your domain:
example.com. TXT "v=spf1 include:_spf.google.com ~all"
This says: "Only Google's servers can send emails from @example.com"
3. Email Security (DKIM)
Provides a cryptographic signature to verify emails haven't been tampered with.
4. Email Security (DMARC)
Tells receiving servers what to do with emails that fail verification.
💡 Tip: If you're setting up a domain for the first time, you'll likely add TXT records for email security and domain verification.
How All Records Work Together
Let's see a complete DNS setup for a small website: myblog.com
The Complete Picture
# Who manages DNS for this domain?
myblog.com. NS ns1.digitalocean.com.
myblog.com. NS ns2.digitalocean.com.
myblog.com. NS ns3.digitalocean.com.
# Where does the website live?
myblog.com. A 167.99.100.50
myblog.com. AAAA 2604:a880:cad:d0::1234:1001
# www is just a nickname for the main domain
www.myblog.com. CNAME myblog.com.
# Where should emails go?
myblog.com. MX 10 mx1.privateemail.com.
myblog.com. MX 20 mx2.privateemail.com.
# Security and verification
myblog.com. TXT "v=spf1 include:spf.privateemail.com ~all"
myblog.com. TXT "google-site-verification=xyz789abc"
What Happens When Someone Visits www.myblog.com?
1. Browser asks: "What's the IP of www.myblog.com?"
↓
2. DNS checks NS records: "Ask ns1.digitalocean.com"
↓
3. Nameserver checks: "www.myblog.com has a CNAME → myblog.com"
↓
4. Nameserver checks: "myblog.com has an A record → 167.99.100.50"
↓
5. Browser connects to 167.99.100.50
↓
6. Website loads! 🎉
What Happens When Someone Emails hello@myblog.com?
1. Email server asks: "Where do I send emails for myblog.com?"
↓
2. DNS checks MX records: "Send to mx1.privateemail.com (priority 10)"
↓
3. Email server connects to mx1.privateemail.com
↓
4. Email is delivered! 📧
Quick Reference Cheat Sheet
| Record | Purpose | Example |
| NS | Who manages DNS? | ns1.provider.com |
| A | Domain → IPv4 address | 192.0.2.1 |
| AAAA | Domain → IPv6 address | 2001:db8::1 |
| CNAME | Domain → Another domain | www → example.com |
| MX | Where to send emails | mail.example.com |
| TXT | Extra info/verification | "google-site-verification=..." |
Common Beginner Confusions Cleared Up
"A Record vs CNAME — Which should I use?"
A Record: When you know the exact IP address
CNAME: When pointing to another domain name (especially third-party services)
Rule: Root domain (
example.com) must use A record. Subdomains can use either.
"NS vs MX — They both point to servers?"
NS: Points to servers that store your DNS records
MX: Points to servers that receive your emails
They're completely different systems!
"Why can't I use CNAME for my root domain?"
Technical limitation. CNAME replaces ALL records for that name, which would break MX records and other essential records. Use an A record for root domains.
Best Practices
Always have at least 2 NS records — Redundancy is important
Keep TTL (Time to Live) reasonable — 300-3600 seconds for most records
Use CNAME for third-party services — Easier to manage if their IPs change
Set up email security records — SPF, DKIM, and DMARC via TXT records
Document your DNS setup — You'll thank yourself later
Common Mistakes to Avoid
Using CNAME for root domain — This will break your email and cause issues
Forgetting MX records — Your emails won't work without them
Pointing to wrong IP — Double-check before saving A records
Not waiting for propagation — DNS changes can take up to 48 hours to spread globally
Conclusion
DNS records are the foundation of how the internet works. Here's what we learned:
DNS is the phonebook of the internet, translating names to addresses
NS Records tell the world who manages your domain's DNS
A Records map your domain to an IPv4 address
AAAA Records map your domain to an IPv6 address
CNAME Records create aliases pointing one name to another
MX Records route emails to the right mail server
TXT Records store verification and security information
Understanding these records makes you a more capable developer who can debug issues, set up domains confidently, and understand what happens behind the scenes.
Next Steps / Further Reading
Set up DNS for a personal project domain
Learn about TTL (Time to Live) and DNS caching
Explore DNS security with DNSSEC
Use
nslookupordigcommands to inspect DNS records
If you found this helpful, consider following for more web development fundamentals explained simply.






