Skip to main content

Command Palette

Search for a command to run...

DNS Record & its Types

Published
6 min readView as Markdown
DNS Record & its Types
R
the topics and concepts which i learn and get more fascinated i write about them here...

How does a browser knows where does a particular website located?

When we type www.google.com into our browser and press Enter, something almost magic happens. Within milliseconds, our browser knows exactly where that website is located and fetches the page for us.

But here is a thing computers don’t understand names like google.com or youtube.com. They only understand numbers which are nothing but IP addresses.

That’s where DNS comes in:

What is DNS?

DNS stands for Domain Name System.

The easiest way to think about DNS is:

DNS is the PhoneBook of Internet.

  • We remember people by names.

  • Our phone remember them by numbers.

Similarly:

  • Humans remember websites by Domain names (google.com)

  • Computers locate them by using IP Addresses (142.250.76.206)

DNS is the system that translates names into numbers. Without DNS we would have to memorize long IP addresses for every website we visit😭. When a user wants to load a webpage, a translation must occur between what a user types into their web browser (example.com) and the machine-friendly address necessary to locate the example.com webpage.

Why DNS records are needed?

DNS records (aka zone files) are instructions that live in authoritative DNS servers and provide information about a domain including what IP address is associated with that domain and how to handle requests for that domain. All DNS records also have a ‘TTL’, which stands for time-to-live, and indicates how often a DNS server will refresh that record.

DNS doesn’t just answer one question.

A domain needs to know:

  • Where the website is located

  • Where emails should go

  • Who is responsible for the domain

  • How different services are connected.

Instead of one big answer, DNS uses records. Each DNS record solves one specific problem.

We can think DNS records like different contact details for the same person.

  • Home address

  • Office Address

  • Email Address

  • Emergency contact

Let’s go through them one by one…

NS Record - Who is responsible for this Domain?

Problem it solves:

Who manages the DNS record for this domain?

An NS(Name Server) record tells the internet which DNS servers are in charge of this domain where the IP address of our domain is stored

Real-life example:

Imagine buying a house in a society.

You need to know: Which society office handles the particular house?

That society office is like the NS record.

In DNS terms:

For example.com, NS records might look like:

example.com → elliott.ns.cloudfare.com

example.com → hera.ns.cloudfare.com

This tells the world that, if we want DNS information for example.com, ask the cloudfare’s servers.

IMP:

  • NS record don’t point to our website

  • Thy point to who controls the DNS

A Record

Problem it solves:

Where is the website actually hostel?

An A record maps a domain name to an IPv4 address.

Example:

example.com → 104.18.27.120

This means, When someone visits example.com, we send them to this server who’s IP is 104.18.27.120

Real-life example:

  • Domain Name → House name

  • IP address → Exact street address

The A record is the most basic and most important DNS record for website.

AAAA Record

Problem it solves:

Same as A record, but for newer IP addresses. An AAAA record maps a domain to an IPv4 address.

Why IPv6 when Ipv4 exists?

  • IPv4 addresses are running out

  • IPv6 provides many more addresses

Example:

example.com → example.com./2606:4700:0:0:0:0:6812:1a78

CNAME Record - One Name Pointing to Another Name

Problem it Solves:

How can multiple names point to the same place?

A CNAME (Canonical Name) record points one domain name to another domain name

Example:

www.example.com → example.com

This means: “www.example.com is just another name for example.com

Real Life example:

  • Official Name: John

  • Nickame: Jonny

Both names refer to same person.

MX Record - How Emails find your main Server

Problem it solves:

Where should emails be delivered?

AN MX (Mail Exchange) record tells email system which server handles email the particular domain.

Example:

example.com → mail.google.com (priority 10)

Real Life Example:

Sending a Letter:

  • Webiste traffice → Goes to your house

  • Emails → Go to the post office first

MX records act like the post office address for the domain.

MX records are only for email, They have priorities (lower number = higher number)

TXT Record - Extra Information & Verification

Service asks:

“Do you own this domain?” → TXT Record → Verification Text

Problem it solves:

How can a domain prove ownership or share instructions?

A TXT record stores plain text information.

Common Uses:

  • Domain ownership verification

  • Email security (SPF, DKIM, DMARC)

  • Service verification (Google, GitHub, AWS)

Example:

example.com → v=spf1 -all

Real life example

Think of TXT records as sticky notes attached to our domain; “Yes, I own this domain.”

One Complete DNS Setup

Meanwhile…

Send email to hello@example.com → MX Record → Google Mail Server → Inbox

Background checks:

  • TXT → Domain Ownership

  • TXT → Email Security

How All DNS Records Work together

Lets say we own example.com

Here’s how everything fits together:

  1. NS records say who manages DNS

  2. A / AAAA records point the website to the server

  3. CNAME records handle aliases like www

  4. MX records route emails

  5. TXT records prove ownership and secure email

A complete simple setup

  • example.com → A → 104.18.27.120

  • www.example.com → CNAME → example.com

  • example.com → MX → mail.google.com

  • example.com → TXT → v=spf1 -all

Everything has a role. Nothing is random

Common confusions

A Record Vs CNAME

  • A → Name → IP address

  • CNAME → Name → Another name

NS Vs MX

  • NS → Who controls DNS

  • MX → Who receives emails

When something breaks

When things stop working, there can be some problem in DNS. Here’s a simple way to think while debugging.

Website not opening?

Check in this order:

  1. NS Record - Is DNS managed by the correct provider?

  2. A / AAAA Record - Is the IP address correct?

  3. CNAME Record - Is it pointing to the right domain?

www not working but main domain works?

  • Check CNAME record for www

Emails not being recieved?

Check:

  1. MX Record - Is it pointing to the correct mail server?

  2. TXT (SPF/DKIM/DMARC) - Are email security records valid?

Domain Verification failing?

  • Double check TXT records(typos are very common)

We can think of debugging DNS as, “Which question is not being answered correctly?”

CheatSheet

Record TypeWhat it DoesSimple Meaning
NSPoints to DNS serversWho controls this domain
ADomain → IPv4Website server address
AAAADomain → IPv6New-format server address
CNAMEName → NameAlias / nickname
MXEmail routingMail server address
TXTExtra infoVerification & security

Conclusion

DNS might sound scary at first, but its actually very logical.

Each record answers one simple question:

  • Who manages this domain?

  • Where is the website?

  • Where should emails go?

  • Is this domain verified?

Once we understand the reason why, the what becomes easy.

If we ever feel confuse we can just remember that;

DNS is just the internet’s phonebook with different sections.