The 6 records that make websites, emails, and the internet work.
How does your browser know where google.com lives?
You type a name. Your computer needs an address. Something has to translate between the two.
That something is DNS (Domain Name System)—and it uses different types of records to answer different questions about a domain.
This article covers:
- What DNS records are and why they exist
- The 6 most important record types: NS, A, AAAA, CNAME, MX, TXT
- Real-world analogies that make each record click
- How all records work together for one website
Part 1: Why DNS Records Exist
The Problem
A single domain like example.com needs to do many things:
- Host a website (where's the web server?)
- Receive emails (where's the mail server?)
- Prove ownership (how do I verify I own this domain?)
- Handle subdomains (what about www, blog, api?)
One domain, many questions. Each question needs a different answer.
The Solution: Different Record Types
Think of DNS like a contact card:
┌─────────────────────────────────────────────────────────────────────────────┐
│ CONTACT CARD ANALOGY │
└─────────────────────────────────────────────────────────────────────────────┘
DNS Records are like fields on a contact card:
┌─────────────────────────────────────────┐
│ EXAMPLE.COM │
│ ───────────────────────────────────── │
│ Office Address: 192.168.1.1 (A) │ ← Where to visit
│ Alternate Name: www → example (CNAME)│ ← Also known as
│ Mail Room: mail.example (MX) │ ← Where to send mail
│ Manager: ns1.host.com (NS) │ ← Who handles inquiries
│ Notes: "Verified" (TXT) │ ← Extra information
└─────────────────────────────────────────┘
Different questions → Different record types!
Part 2: The Big Picture
Before diving into each record, here's how they fit together:
┌─────────────────────────────────────────────────────────────────────────────┐
│ HOW DNS RECORDS WORK TOGETHER │
└─────────────────────────────────────────────────────────────────────────────┘
User types: example.com
│
▼
┌─────────────────┐
│ DNS RESOLVER │ "Let me look up this domain..."
└────────┬────────┘
│
│ Checks NS record: "Who manages example.com?"
▼
┌─────────────────┐
│ NS RECORD │ → ns1.dnshost.com (authoritative server)
└────────┬────────┘
│
│ Asks authoritative server for A record
▼
┌─────────────────┐
│ A RECORD │ → 93.184.216.34 (website IP)
└────────┬────────┘
│
▼
Browser connects to 93.184.216.34 → Website loads!
─────────────────────────────────────────────────────────────
Meanwhile, for email:
someone@example.com
│
▼
┌─────────────────┐
│ MX RECORD │ → mail.example.com (mail server)
└────────┬────────┘
│
▼
Email delivered to mail server!
Now let's understand each record type.
Part 3: NS Record — Who's In Charge
The Question It Answers
"Who should I ask for information about this domain?"
The Analogy: Main Office Directory
Imagine you want to know about a company. First, you need to find their main office that handles all inquiries. That's what an NS record does.
NS = Name Server — The server that has the official information about a domain.
Example
example.com. IN NS ns1.dnshost.com.
example.com. IN NS ns2.dnshost.com.
This says: "For any questions about example.com, ask ns1.dnshost.com or ns2.dnshost.com."
Why NS Records Matter
| Purpose | Explanation |
|---|---|
| Delegation | NS records tell the internet who controls a domain |
| Redundancy | Multiple NS records = backup if one server is down |
| Domain Transfer | Change NS records to move your domain to a new host |
Real-World Use Case
When you buy a domain from GoDaddy but host on Cloudflare:
Before: example.com NS → ns1.godaddy.com
After: example.com NS → ns1.cloudflare.com
Now Cloudflare controls your domain's DNS!
Part 4: A Record — The Main Address
The Question It Answers
"What's the IPv4 address of this website?"
The Analogy: House Street Address
The A record is like a street address. When someone asks "Where does google.com live?", the A record gives the physical location (IP address).
A = Address — The IPv4 address where the domain points.
Example
google.com. IN A 142.250.193.46
This says: "google.com is at IP address 142.250.193.46"
Diagram: How A Records Work
┌─────────────────────────────────────────────────────────────────────────────┐
│ A RECORD MAPPING │
└─────────────────────────────────────────────────────────────────────────────┘
Human-readable Machine-readable
┌──────────────┐ ┌────────────────┐
│ google.com │ ─── A ────► │ 142.250.193.46 │
└──────────────┘ └────────────────┘
┌──────────────┐ ┌────────────────┐
│ github.com │ ─── A ────► │ 140.82.112.4 │
└──────────────┘ └────────────────┘
┌──────────────┐ ┌────────────────┐
│ example.com │ ─── A ────► │ 93.184.216.34 │
└──────────────┘ └────────────────┘
The browser uses this IP to connect to the server!
Multiple A Records = Load Balancing
Large sites can have multiple A records:
google.com. IN A 142.250.193.46
google.com. IN A 142.250.193.78
google.com. IN A 142.250.80.46
DNS returns different IPs to different users, distributing traffic!
Part 5: AAAA Record — The Modern Address
The Question It Answers
"What's the IPv6 address of this website?"
The Analogy: Same House, New Postal Code Format
Remember IPv4 addresses like 142.250.193.46? We ran out of them.
IPv6 is the new format with virtually unlimited addresses. An AAAA record is like an A record, but for the new system.
AAAA = IPv6 Address (Four A's because IPv6 is 4x longer than IPv4)
Example
google.com. IN AAAA 2607:f8b0:4004:800::200e
Why IPv6?
| IPv4 | IPv6 |
|---|---|
| ~4.3 billion addresses | 340 undecillion addresses |
142.250.193.46 |
2607:f8b0:4004:800::200e |
| Running out | Unlimited for practical purposes |
Do You Need AAAA Records?
| If Your Site... | AAAA Record? |
|---|---|
| Is on a modern host | Probably already set up |
| Needs to reach IPv6-only users | Yes, required |
| Is internal/small | Optional but good practice |
Part 6: CNAME Record — The Nickname
The Question It Answers
"This name is an alias—what's the real name?"
The Analogy: "Also Known As"
Sometimes one name points to another name. Like how "Bill" is an alias for "William."
CNAME = Canonical Name — An alias from one domain name to another.
Example
www.example.com. IN CNAME example.com.
blog.example.com. IN CNAME example.github.io.
-
www.example.com→ "Just useexample.com" -
blog.example.com→ "Actually go toexample.github.io"
Diagram: How CNAME Works
┌─────────────────────────────────────────────────────────────────────────────┐
│ CNAME POINTING TO ANOTHER NAME │
└─────────────────────────────────────────────────────────────────────────────┘
User visits: www.example.com
│
▼
┌─────────────────┐
│ CNAME Record │ www.example.com → example.com
└────────┬────────┘
│ (Follow the alias)
▼
┌─────────────────┐
│ A Record │ example.com → 93.184.216.34
└────────┬────────┘
│
▼
Browser connects to 93.184.216.34
─────────────────────────────────────────────────────────────
CNAME is like a redirect: "Don't look here, look THERE"
⚠️ Common Confusion: A vs CNAME
| Record Type | Points To | Use When |
|---|---|---|
| A | IP address (142.250.193.46) |
You know the exact IP |
| CNAME | Another domain name (example.com) |
You want an alias |
Key Rule: CNAME points to a NAME. A record points to an ADDRESS.
Another Rule: You can't use CNAME at the root domain (example.com). Use it only for subdomains (www.example.com, blog.example.com).
When to Use CNAME
| Scenario | Use CNAME? |
|---|---|
www.example.com → example.com
|
✅ Yes |
| Hosting blog on GitHub Pages | ✅ Yes (blog.example.com → user.github.io) |
| Root domain to IP | ❌ No, use A record |
Part 7: MX Record — Email Routing
The Question It Answers
"Where should emails for this domain go?"
The Analogy: Post Office
Imagine your domain is a building. Visitors go to the front door (A record). But mail goes to a separate post office (MX record).
MX = Mail Exchange — The server that handles email for a domain.
Example
example.com. IN MX 10 mail.example.com.
example.com. IN MX 20 backup-mail.example.com.
The Priority Number
MX 10 mail.example.com. ← Try this FIRST (lower = higher priority)
MX 20 backup-mail.example.com. ← Try this if first fails
Lower number = Higher priority. Email servers try them in order.
Diagram: Email Routing with MX
┌─────────────────────────────────────────────────────────────────────────────┐
│ MX RECORD EMAIL ROUTING │
└─────────────────────────────────────────────────────────────────────────────┘
Email sent to: hello@example.com
│
▼
┌─────────────────┐
│ Sender's server │ "Where does example.com receive mail?"
└────────┬────────┘
│
│ Looks up MX record
▼
┌─────────────────┐
│ MX Record │ Priority 10: mail.example.com
│ │ Priority 20: backup-mail.example.com
└────────┬────────┘
│
│ Tries mail.example.com first
▼
┌─────────────────┐
│ Mail Server │ Email delivered!
└─────────────────┘
⚠️ Common Confusion: NS vs MX
| Record | Purpose | Controls |
|---|---|---|
| NS | Who manages DNS for the domain | DNS queries |
| MX | Who receives email for the domain | Email delivery |
NS is about DNS control. MX is about email delivery.
Real-World MX Setup
Using Gmail for business email:
example.com. IN MX 1 ASPMX.L.GOOGLE.COM.
example.com. IN MX 5 ALT1.ASPMX.L.GOOGLE.COM.
example.com. IN MX 5 ALT2.ASPMX.L.GOOGLE.COM.
Part 8: TXT Record — The Notes Field
The Question It Answers
"What extra information is associated with this domain?"
The Analogy: Sticky Notes
TXT records are like sticky notes attached to your domain. They hold text that proves ownership or provides security information.
TXT = Text — Any text data attached to a domain.
Example
example.com. IN TXT "v=spf1 include:_spf.google.com ~all"
example.com. IN TXT "google-site-verification=abc123xyz"
Common Uses
| Use Case | Example TXT Content |
|---|---|
| Domain Verification | google-site-verification=abc123 |
| SPF (Email Security) | v=spf1 include:_spf.google.com ~all |
| DKIM (Email Signing) | v=DKIM1; k=rsa; p=MIGf... |
| DMARC (Email Policy) | v=DMARC1; p=reject |
Domain Verification Example
When you add a domain to Google Search Console:
- Google gives you a code:
google-site-verification=abc123xyz - You add a TXT record:
example.com TXT "google-site-verification=abc123xyz" - Google checks for this record
- Ownership verified!
Why TXT Records Matter for Developers
| Service | Uses TXT For |
|---|---|
| Google Workspace | Domain verification |
| SSL Certificates | Domain control validation |
| Email Providers | SPF, DKIM, DMARC |
| CDN Providers | Ownership proof |
Part 9: All Records Working Together
Let's see a complete DNS setup for a small website.
Scenario: Small Business Website
Domain: mybusiness.com
Needs:
- Website hosted on a server
- www subdomain working
- Business email via Google Workspace
- SSL certificate verification
Complete DNS Configuration
┌─────────────────────────────────────────────────────────────────────────────┐
│ COMPLETE DNS SETUP FOR mybusiness.com │
└─────────────────────────────────────────────────────────────────────────────┘
Record Type Name Value Purpose
─────────────────────────────────────────────────────────────────────────────
NS mybusiness.com ns1.cloudflare.com. DNS management
NS mybusiness.com ns2.cloudflare.com. (backup)
A mybusiness.com 203.0.113.50 Website server
AAAA mybusiness.com 2001:db8::1 IPv6 for website
CNAME www mybusiness.com www → root domain
CNAME blog mybusiness.github.io Blog on GitHub
MX mybusiness.com ASPMX.L.GOOGLE.COM. (1) Email via Gmail
MX mybusiness.com ALT1.ASPMX.L.GOOGLE.COM.(5) Backup mail
TXT mybusiness.com "v=spf1 include:_spf.google.." Email security
TXT mybusiness.com "google-site-verification=..." Ownership proof
Diagram: How They Work Together
┌─────────────────────────────────────────────────────────────────────────────┐
│ ONE DOMAIN, MULTIPLE RECORDS, DIFFERENT PURPOSES │
└─────────────────────────────────────────────────────────────────────────────┘
mybusiness.com
│
┌─────────────────────────┼─────────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐
│ NS │ │ A/AAAA │ │ MX │
│ Records │ │ Records │ │ Records │
└─────┬─────┘ └─────┬─────┘ └─────┬─────┘
│ │ │
▼ ▼ ▼
Cloudflare Web Server Gmail Servers
(controls DNS) (203.0.113.50) (handles email)
│
▼
┌───────────┐
│ CNAME │ www.mybusiness.com → mybusiness.com
│ Records │ blog.mybusiness.com → github.io
└───────────┘
│
▼
┌───────────┐
│ TXT │ SPF for email security
│ Records │ Domain verification
└───────────┘
Part 10: Quick Reference
Record Types Summary
| Record | Purpose | Points To | Example |
|---|---|---|---|
| NS | Who controls DNS | Name server domain | ns1.cloudflare.com |
| A | Website address (IPv4) | IP address | 142.250.193.46 |
| AAAA | Website address (IPv6) | IPv6 address | 2607:f8b0:... |
| CNAME | Alias/redirect | Another domain name | example.com |
| MX | Email server | Mail server domain + priority | 10 mail.google.com |
| TXT | Extra info | Any text | v=spf1 include:... |
When to Use Each Record
| I Want To... | Use This Record |
|---|---|
| Point domain to a server | A (or AAAA for IPv6) |
| Make www work | CNAME (www → root) |
| Receive email | MX |
| Verify domain ownership | TXT |
| Change DNS provider | NS |
| Create subdomain alias | CNAME |
Quick Commands to Check Records
# Check A record
dig example.com A +short
# Check MX records
dig example.com MX +short
# Check NS records
dig example.com NS +short
# Check TXT records
dig example.com TXT +short
# Check all records
dig example.com ANY +short
Conclusion
DNS records are the backbone of how the internet routes traffic.
| Record | One-Line Summary |
|---|---|
| NS | "Who controls this domain's DNS" |
| A | "The IPv4 address of this domain" |
| AAAA | "The IPv6 address of this domain" |
| CNAME | "This name is an alias for that name" |
| MX | "Where emails should go" |
| TXT | "Extra notes attached to the domain" |
The key insight: Each record answers a different question. When you understand what question each record answers, DNS stops being mysterious.
Now you can confidently set up and debug DNS for any domain. Go make the internet work! 🌐
Top comments (0)