DNS Record Types Explained
Exploring Various DNS Record Types

Hi, I’m Abdul Samad. A web development learner and tech enthusiast. I write about what I learn, share practical coding tips, and publish in-depth blogs on programming and modern web development.
Check out my full collection of blogs on Hashnode: https://abdulsamad30.hashnode.dev/
Connect with me on X for quick updates and insights: @abdul_sama60108
1. How DNS Works : From Domain Name to IP Address
When you want to visit a website like youtube.com, you just type the name in your browser. This name is easy for humans to remember, but computers don’t understand it. Computers need the IP address of the website to connect, something like 207.223.160.0.
So the domain name (youtube.com) is for humans, while the IP address (207.223.160.0) is what computers use to actually find the website.
You might wonder: “I don’t type any IP address, so how does my computer find it?”
1.1 This is where DNS comes in.
DNS stands for Domain Name System. It’s like the internet’s phone book.
You give it a domain name like
youtube.com.DNS finds the corresponding IP address and gives it to your browser.
Your browser then uses the IP to connect to the website.
Think of it like your mobile phone contacts:
You save your friend’s name along with their phone number.
You search by name because it’s easy to remember, but your phone uses the number to actually make the call.
Similarly, DNS lets you search websites by name while the computer connects using the IP address. From a top-level view, DNS is essentially a phone book for the internet.
Example: Domain Names and IP Addresses
| Domain Name | IP Address |
| youtube.com | 207.223.160.0 |
| google.com | 142.250.190.78 |
| facebook.com | 157.240.22.35 |
| twitter.com | 104.244.42.1 |
1.2 Understand the flow of DNS through Diagram

If you want to know more about DNS and how it works internally, including root servers, TLD servers, and authoritative servers visit this blog : https://abdulsamad30.hashnode.dev/how-dns-resolution-works
Now its time to come on or main topic :
“1. Why DNS records are needed” & “2.DNS Record Types Explained”
First come on this :
2. Why DNS records are needed
A domain name by itself is just a label, nothing more. It is like writing a person’s name on a piece of paper. That name alone does not tell you their phone number, their house address, or how to contact them. DNS records are needed to attach useful information to that name.
DNS records tell the internet what services exist for a domain and where they are located. When someone opens a website, sends an email, or checks security rules, the internet looks at the DNS records to decide what to do. Without records, the internet has no instructions.
Think of DNS records like notes attached to a contact in your phone. The contact name is the domain. The notes contain the phone number, email address, and other details. DNS records store these details in a technical but organized way so computers can understand them.
DNS records also help keep things clear and organized. One record handles the website, another handles email, another handles security checks. This separation avoids confusion and allows each service to work independently without breaking others.
Some common DNS record names you will see are A, AAAA, CNAME, MX, TXT, NS. Each record has a specific role, but the main idea is simple. Together, they tell the internet how a domain should behave.
2.1 A Record (domain → IPv4 address)
An A record links a domain name to a specific IP address so the website can be found on the internet.

2.2 AAAA Record is (domain → IPv6 address)
An AAAA record is similar to an A record, but it maps a domain name to an IPv6 address instead of an IPv4 address.

2.3 CNAME Record is (one name pointing to another name)
Why CNAME Records Are Useful
A CNAME record points one domain to another domain instead of an IP address. This is especially helpful when you use platforms like Vercel to host your website.
1. Using a Custom Domain with an A Record
Suppose you deploy a project on Vercel. Vercel automatically gives your project a default subdomain, like:
myapp.vercel.app
Now, you want visitors to access your site using your custom domain :
www.mycustomdomain.com

If you try to use an A record for this custom domain:
You have to point
www.mycustomdomain.comdirectly to the IP address of the Vercel server hosting your project.
Problem : Vercel does not provide a fixed IP address. The underlying server or IP can change anytime for maintenance, traffic scaling, or infrastructure updates.
Result: If Vercel changes the IP, your website stops working until you manually update the A record.
Example scenario :
Your project URL:
myapp.vercel.appYour custom domain:
www.mycustomdomain.comIf you set
www.mycustomdomain.com → 76.76.21.21(A record) and Vercel moves your project to a new server with IP76.76.22.33, your domain will no longer reach the site until you change the A record.
This is why using an A record with Vercel is risky it can easily break your custom domain if the platform changes the server or IP behind the scenes.

2.3.1 Using a Custom Domain with a CNAME Record
If you use a CNAME record instead:
You point your custom domain
www.mycustomdomain.comto the Vercel domainmyapp.vercel.appinstead of an IP.Now, if Vercel changes the server or IP, your domain automatically follows it.
You never have to update your DNS manually.
2.3.2 Extra Benefits of CNAME
Multiple aliases (like
blog.mycustomdomain.comorshop.mycustomdomain.com) can point to the same project easily.Reduces mistakes and ensures your site stays online, even if the hosting platform changes infrastructure.
Example :
Your Vercel project:
myapp.vercel.appCustom domain:
www.mycustomdomain.comCNAME setup:
www.mycustomdomain.com → myapp.vercel.appLater, Vercel moves your project to a new server with a different IP. Your domain still works automatically.
In short:
Using a CNAME record for custom domains is safer and more flexible than an A record. It ensures your website stays online even if your hosting platform changes servers or IPs.
2.4 What an NS Record Is
An NS (Name Server) record tells the internet which servers are responsible for managing a domain. Think of it like a manager for your domain it knows where all the other records (A, CNAME, MX, etc.) live and answers questions about your domain. Without NS records, the internet wouldn’t know who controls your domain.
2.4.1 The Scenario
Let’s say you want to host your project on Vercel. Vercel gives you a default URL:
myapp.vercel.app
You want your custom domain www.mycustomdomain.com to point to this Vercel project.
Here’s the step-by-step workflow:
2.4.2 Step 1: Register Your Domain
You buy the domain mycustomdomain.com from a registrar like GoDaddy or Namecheap. When you register the domain, the registrar automatically assigns default name servers, for example:
ns1.godaddy.com
ns2.godaddy.com
These are the NS records the servers that “manage” your domain. All DNS requests for your domain will go to these servers first.
2.4.3 Step 2: Point the Domain to a DNS Provider (Optional)
If you want more control or features (like free SSL or better management), you might use a service like Cloudflare to manage your DNS.
- You change the NS records at your registrar to Cloudflare’s servers:
emma.ns.cloudflare.com
hank.ns.cloudflare.com
- Now, Cloudflare’s servers are responsible for your domain. All DNS records (A, CNAME, MX, TXT) will be managed on Cloudflare.
2.4.5 Step 3: Connect Your Domain to Vercel
Next, on Vercel, you add your custom domain www.mycustomdomain.com. Vercel will tell you to add a CNAME record pointing your domain to your Vercel project:
www.mycustomdomain.com → myapp.vercel.app
- When someone types
www.mycustomdomain.comin their browser, here’s what happens:
The browser asks the internet: “Who is responsible for mycustomdomain.com?”
The query goes to the NS servers (
emma.ns.cloudflare.com&hank.ns.cloudflare.com).The NS servers reply: “I have the DNS records. For the website, check the CNAME: www.mycustomdomain.com → myapp.vercel.app.”
The browser then connects to Vercel at
myapp.vercel.appand loads your website.
2.4.6 Why NS Records Are Important
Define authority: NS records tell the internet which DNS servers to ask for information about your domain.
Foundation for all DNS records: Without NS records, A, CNAME, MX, or TXT records won’t work because there’s no authority to provide them.
Easy to move: If you switch DNS providers (like from GoDaddy to Cloudflare), you just update the NS records. All other records stay intact.
Supports workflows like Vercel: Using NS + CNAME allows your custom domain to follow Vercel even if Vercel changes servers or IPs.
2.4.7 Real-World Analogy
Think of your domain as a company name:
The NS record is the reception desk of the company it knows where every department is located.
The CNAME or A records are like signboards inside the building, pointing visitors to the website, email server, or other services.
Without a reception desk (NS record), visitors would have no idea where to go.
In short :
NS records tell the internet who is in charge of your domain. They are the first point of contact for all DNS queries and make sure your domain’s website, email, and other services work correctly.
2.5 What an MX Record Is (How Emails Find Your Mail Server)
An MX (Mail Exchange) record tells the internet which server is responsible for handling emails for your domain. Think of it like the postal office for your domain it knows exactly where to deliver incoming emails. Without MX records, no one could send you emails because the internet wouldn’t know where to go.
2.5.1 The Scenario
Let’s say you want to receive emails at your custom domain:
You plan to use Gmail to manage your email.
Here’s the step-by-step workflow:
2.5.2 Step 1: Register Your Domain
You buy the domain mycustomdomain.com from a registrar like GoDaddy or Namecheap. By default, your domain has NS records like:
ns1.godaddy.com
ns2.godaddy.com
These NS records manage all DNS requests for your domain.
At this point, your domain can host a website, but emails won’t work yet because there are no MX records pointing to an email server.
2.5.3 Step 2: Add MX Records to Your DNS
To use Gmail for your emails, Google provides MX records like:
ASPMX.L.GOOGLE.COM priority 1
ALT1.ASPMX.L.GOOGLE.COM priority 5
ALT2.ASPMX.L.GOOGLE.COM priority 5
ALT3.ASPMX.L.GOOGLE.COM priority 10
ALT4.ASPMX.L.GOOGLE.COM priority 10
Here’s what happens when you add them:
You log into your DNS provider (GoDaddy, Cloudflare, etc.).
You add the MX records exactly as Google specifies.
Each record has a priority lower numbers are tried first.
Now your domain knows Gmail is responsible for handling all incoming emails.
2.5.4 Step 3: How Email Delivery Works
When someone sends an email to you@mycustomdomain.com, the process is:
The sender’s email server asks: “Who handles email for mycustomdomain.com?”
The query goes to the NS servers (
ns1.godaddy.com,ns2.godaddy.com).The NS servers reply with the MX records pointing to Google’s mail servers.
The sender’s email server connects to the Google mail server with the lowest priority and delivers the email.
Gmail receives the email and stores it in your inbox.
2.5.5 Why MX Records Are Important
Define authority for email: MX records tell the internet which mail server is responsible for your domain. Without them, emails can’t reach you.
Prioritize servers: Multiple MX records with different priorities ensure email delivery even if one server is down.
Flexible and portable: You can switch email providers (like Gmail to Outlook) just by updating MX records.
Works with custom domains: Using MX records, you can receive emails at you@mycustomdomain.com while using third-party email services.
In short :
MX records tell the internet where emails for your domain should go. They work alongside NS records to make sure your domain’s email system is reliable, efficient, and ready to receive messages.

2.6 What a TXT Record Is (Extra Information and Verification)
A TXT (Text) record allows domain owners to attach extra information to their domain in the DNS. This information can be anything, but in practice, it’s often used for verification, email security, or ownership proof. Think of it like leaving a sticky note on your building saying, “This is my domain, and here’s some info about it.”
Without TXT records, services like Google Workspace, Microsoft 365, or SPF/DKIM email protection wouldn’t know your domain is valid.
2.6.1 The Scenario
Let’s say you want to use Google Workspace to send and receive emails from:
Google needs to verify you own the domain and optionally improve email security. That’s where TXT records come in.
2.6.2 Step 1: Register Your Domain
You buy the domain mycustomdomain.com from a registrar (GoDaddy, Namecheap, etc.).
Your NS records might be:
ns1.godaddy.com
ns2.godaddy.com
These NS servers are in charge of answering DNS queries for your domain. At this point, no extra info (TXT) has been added yet.
2.6.3 Step 2: Add TXT Records for Verification or Security
Google gives you a TXT record to verify your domain, for example:
google-site-verification=abcd1234xyz
And for email security, you might add SPF/DKIM TXT records:
v=spf1 include:_spf.google.com ~all
Here’s what happens:
You log in to your DNS provider (GoDaddy, Cloudflare, etc.).
You add the TXT records exactly as Google specifies.
These records now tell anyone (or any service) querying your domain:
“Yes, Google Workspace is allowed to manage email for this domain.”
“Here’s verification info showing the domain is owned by this account.”
2.6.4 Step 3: How TXT Records Work in Practice
When Google or another service wants to verify your domain or check email authenticity:
They ask the NS servers:
“Do you have any TXT records for mycustomdomain.com?”
The NS servers reply with the TXT records, e.g.:
google-site-verification=abcd1234xyz
v=spf1 include:_spf.google.com ~all
The service reads this information and can:
Confirm you own the domain (verification) — this happens only the first time you sign up for a service like Google Workspace or Microsoft 365.
Check that emails coming from your domain are allowed (SPF/DKIM)
SPF: A DNS TXT record that tells email servers which servers are allowed to send emails for your domain.
DKIM: A cryptographic signature added to outgoing emails to verify they really came from your domain and weren’t tampered with.
After the first-time verification, the TXT record for domain ownership is no longer checked, but SPF/DKIM TXT records continue to be used whenever an email is sent or received.
Without this information, services couldn’t trust your domain or deliver your emails securely.
2.6.5 Why TXT Records Are Important
Domain verification: Prove ownership of your domain to services like Google, Microsoft, or SSL certificate providers.
Email security: SPF, DKIM, and DMARC TXT records prevent spammers from sending fake emails from your domain.
Flexible info storage: Any text info, instructions, or metadata about your domain can be stored in DNS.
Works with existing NS setup: You don’t need to change NS records; TXT works alongside other records.
In short:
TXT records add extra info and verification details to your domain. They don’t direct traffic like A, CNAME, or MX records, but they are essential for domain ownership, email authentication, and security.

3. Common Confusion
3.1 A vs CNAME
A common beginner mistake is using an A record for modern hosting platforms like Vercel or Netlify. An A record points to a fixed IP address, but these platforms change IPs behind the scenes. When the IP changes, the site can break unless the record is updated manually.
On the other hand, beginners often misuse CNAME records by trying to place them on the root domain (like example.com). Many DNS providers don’t allow CNAMEs at the root because it conflicts with other required records. CNAMEs are best used for subdomains like www, where they can safely follow another domain.
A simple rule use an A record when you control the server and its IP. Use a CNAME when you don’t control the IP and want DNS to follow another domain automatically.
3.2 NS vs MX
Beginners often think NS records control where the website or emails go. That’s not correct. NS records only tell the internet which DNS provider is authoritative for the domain. They don’t route traffic or emails themselves.
Another common confusion is thinking MX records manage DNS. MX records do only one thing: they tell mail servers where to deliver emails. They have nothing to do with websites, IPs, or DNS authority.
A simple rule: NS decides who is in charge of the domain, and MX decides where emails go.
4. How all DNS records work together for one website
This diagram shows how a single domain uses A/CNAME, NS, MX, and TXT records together.







