DEV Community

Harsh
Harsh

Posted on

DNS Record Types Explained

How does a browser know where a website lives?

When you type:

www.google.com
Enter fullscreen mode Exit fullscreen mode

into your browser, your computer somehow finds the exact machine in the world that runs Google’s website.

But computers don’t understand names like google.com.

They only understand IP addresses, such as:

142.250.195.78
Enter fullscreen mode Exit fullscreen mode

So the real question becomes:

How does a human-friendly name turn into a machine-friendly address?

That’s where DNS comes in.


What is DNS?

DNS stands for Domain Name System.
DNS is basically the phonebook of the internet.

Similar as

  • You search a person’s name → get their phone number
  • The browser searches a domain name → gets an IP address

Without DNS, you would have to remember numbers instead of names:

142.250.195.78 instead of google.com 
Enter fullscreen mode Exit fullscreen mode

DNS makes the internet usable for humans.

Browser → DNS → Server high-level flow diagram

Why are DNS records needed?

A domain name doesn’t store information by itself.
DNS records are the instructions attached to a domain.
They answer questions like:

  • Who controls this domain?
  • Where is the website hosed?
  • Where should emails go?
  • Is this domain verified for some service?

Each DNS record solves one specific problem.
Instead of one giant setting, DNS uses different record types, each with a clear job.


What is an NS Record?

NS = Name Server

NS records tell the internet:

“These servers are responsible for this domain.”

Think of NS records like the main office of a society that knows where every house is.

Example:

example.com → ns1.cloudflare.com
               ns2.cloudflare.com
Enter fullscreen mode Exit fullscreen mode

This means Cloudflare’s servers manage all DNS information for example.com.

Without NS records, no one would know where to even ask about your domain.

meme related to cloud flare


What is an A Record?

A = Address

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

Example:

example.com → 93.184.216.34
Enter fullscreen mode Exit fullscreen mode

This tells the browser:

“The website lives on this machine.”

Think of it like a house address.

Domain name = person
IP address = house location


What is an AAAA Record?

AAAA records do the same job as A records but for IPv6 addresses (the newer, longer IP format).

Example:

example.com → 2606:2800:220:1:248:1893:25c8:1946
Enter fullscreen mode Exit fullscreen mode

Why both exist?

Because the internet is slowly moving from IPv4 → IPv6.

Many websites use both A and AAAA records so all networks can reach them.


What is a CNAME Record?

CNAME = Canonical Name

A CNAME record points one domain name to another domain name.

Example:

www.example.com → example.com
Enter fullscreen mode Exit fullscreen mode

So instead of storing an IP address, it says:

“Go ask that domain instead.”

This is very useful when:

  • multiple names should lead to the same site
  • the main domain’s IP changes

Think of CNAME like a contact saved under another contact.


What is an MX Record?

MX = Mail Exchange

MX records tell the internet:

“Emails for this domain should go here.”

Example:

example.com → mail.google.com
Enter fullscreen mode Exit fullscreen mode

When someone sends:

hello@example.com
Enter fullscreen mode Exit fullscreen mode

MX records guide that email to the correct mail server.

Important:

  • Websites use A / CNAME
  • Emails use MX

They solve totally different problems.


What is a TXT Record?

TXT records store text-based information.
They are commonly used for:

  • Domain ownership verification
  • Email security (SPF, DKIM, DMARC)
  • Connecting domains to services (GitHub, Google, Cloudflare, etc.)

Example:

"google-site-verification=abc123"
Enter fullscreen mode Exit fullscreen mode

Think of TXT records as note papers attached to your domain.
They don’t move traffic, they prove trust and provide info.


How all DNS records work together for one website

Let’s say you run a small website: myblog.com

Behind the scenes, DNS might look like:

  • NS → who manages the domain
  • A / AAAA → where the website lives
  • CNAME → connect subdomains
  • MX → where emails go
  • TXT → verification & security

All records work together like departments in a company.


Final Thoughts

A Record vs CNAME

  • A Record → points to an IP
  • CNAME → points to another name

A = final house
CNAME = redirect board

NS vs MX

  • NS → who controls the domain
  • MX → who handles emails

NS is about DNS authority
MX is about email delivery

DNS is not one thing.
It’s a collection of small instruction cards attached to your domain.

Each card answers one clear question:

  • Where is the site?
  • Who manages this domain?
  • Where should emails go?
  • Is this domain verified?

Once you understand that DNS stops feeling scary and starts feeling logical.

Top comments (0)