DNS Record Types Explained
MERN Stack Developer
What is DNS?
DNS (Domain Name System) is like the phonebook of the internet.
When you type a website name (like example.com DNS), it translates that friendly name into a numeric address (like 192.0.2.1) that computers can understand.
Why are DNS records needed?
A single website needs more than just one piece of information to work properly. It needs to know.
DNS records are individual entries in the DNS system that store different types of information about a domain. Each record type solves a specific problem
Where the website files are stored
Where to send emails
Who is in charge of managing the domain
How to handle different services (like mobile versions or subdomains)
What an NS Record
NS stands for Name Server. Think of it like the property manager for an apartment building. When someone needs information about the building, they go to the property manager, who has all the details.
An NS record :- If you want to know anything about this domain ask these specific DNS servers—they're the official source.
Example:
example.com NS ns1.hostingcompany.com
example.com NS ns2.hostingcompany.com
What an NS Record (IPv6)
Problem it solves: The internet is running out of IPv4 addresses! IPv6 is the newer, larger address system.
AAAA (pronounced "quad A") does exactly the same thing as an A record, but for IPv6 addresses instead. IPv6 addresses look like this.
Example:
example.com AAAA 2001:0db8:85a3::8a2e:0370:7334
Real-world: Some people still use landlines (IPv4), while others only have cell phones (IPv6). You might list both numbers so anyone can reach you.
Most modern websites have both A and AAAA records pointing to the same service.
What is a CNAME Record
CNAME stands for Canonical Name. It's like giving something a nickname. Instead of pointing directly to an IP address, a CNAME points to another domain name.
Example:
www.example.com CNAME example.com
shop.example.com CNAME shopify.mystore.com
The first line means "www.example.com is just another name for example.com—look up example.com instead."
Real-world : Your friend Rohit goes by "Bob." When someone asks for Bob, you say, "That's Rohit—look him up." You don't need to remember two separate addresses because Bob and Rohitt are the same person.
What an MX Record is (how emails find your mail server)
MX stands for Mail Exchange. This record tells the internet which server handles email for your domain.
Example:
example.com MX 10 mail.example.com
example.com MX 20 backup-mail.example.com
The number (10, 20) is the priority—lower numbers are tried first. If the first mail server is down, email gets sent to the backup.
Real-world: It's like telling people, "If you need to send me mail, send it to the Oak Street Post Office. If they're closed, try the Elm Street location."
Common beginner confusion: NS vs MX
NS record: Says, "Ask this DNS server for information about my domain."
MX record: Says "send emails to this mail server"
Both delegate responsibility, but for completely different jobs! NS is about DNS management; MX is about email delivery.
Why not just use A records for email? Because you might want your website hosted at one company and your email hosted at another (like Google Workspace or Microsoft 365).
What a TXT Record is (extra information and verification)
TXT stands for Text. It's a flexible record type that can hold any text information. It's like the notes section of a contact card.
Common uses:
Proving you own the domain (for Google, Microsoft, etc.)
Email security (SPF, DKIM, DMARC)
Example:
example.com TXT "v=spf1 include:_spf.google.com ~all"
example.com TXT "google-site-verification=abc123xyz"
The first one tells email servers, "Only trust emails from Google's servers for this domain." The second one proves to Google that you own this domain.
Real-world : Like notes on a business card: "Preferred contact method: email" or "Member since 2026"
TXT records are also used for things like domain ownership verification when setting up services. A company might say, "Add this specific text to your DNS to prove you control this domain."
How All These Records Work Together
Let's see how a complete website uses multiple DNS records working in harmony. Imagine you run a small online store called shopexample.com.
Your complete DNS setup:
; Name servers (who manages DNS)
shopexample.com NS ns1.cloudflare.com
shopexample.com NS ns2.cloudflare.com
; Website addresses
shopexample.com A 203.0.113.10
shopexample.com AAAA 2001:db8::10
www.shopexample.com CNAME shopexample.com
; Additional services
blog.shopexample.com A 203.0.113.50
api.shopexample.com CNAME api-gateway.cloud-provider.com
; Email routing
shopexample.com MX 10 mail.google.com
shopexample.com MX 20 backup-mail.google.com
; Verification and security
shopexample.com TXT "v=spf1 include:_spf.google.com ~all"
shopexample.com TXT "google-site-verification=xyz789"
What happens when someone visits your website:
The browser asks, "Where is shopexample.com?"
The DNS system checks the NS records: "The authoritative DNS servers are at Cloudflare; let me ask them."
Cloudflare's DNS responds with the A record: "shopexample.com is at 203.0.113.10."
Browser connects: Your browser now knows the IP address and loads the website!
What happens when someone sends you an email:
The email server asks, "Where do emails for shopexample.com go?"
DNS returns the MX records: "Try mail.google.com first (priority 10), or backup-mail.google.com if that fails (priority 20)."
Email gets delivered to Google's servers, which handle your email.
What happens when someone visits www.shopexample.com:
The browser asks, "Where is www.shopexample.com?"
DNS returns the CNAME: "www.shopexample.com is an alias for shopexample.com."
DNS then returns the A record for shopexample.com: "That's at 203.0.113.10."
The browser connects to the same place as the main domain.
All these records work together like a well-organized filing system, each solving a specific problem and making the internet work seamlessly.