DEV Community

Cover image for DNS Record Types Explained
Janmejai Singh
Janmejai Singh

Posted on

DNS Record Types Explained

DNS Record Types Explained: The Phonebook Behind Every Website You Visit

Here's a question that sounds simple but trips up a lot of beginner developers: when you type example.com into your browser, how does it actually know which server, sitting in some data center halfway across the world, to talk to?

The answer is DNS — the Domain Name System — and once you understand it, a whole bunch of "mysterious" web dev concepts (deploying a site, setting up email, verifying a domain for Google or AWS) suddenly stop feeling like magic.

Let's walk through it slowly, one piece at a time.

What DNS Is (In Very Simple Terms)

Computers don't actually use names like example.com to find each other. Underneath everything, they use numbers — IP addresses — like 192.0.2.10. That's how machines on a network identify each other.

But humans are terrible at remembering strings of numbers, and great at remembering names. So DNS exists as a translation layer: you type a friendly name, and DNS quietly converts it into the numeric address a computer needs.

Think of DNS as the phonebook of the internet. You don't memorize your friend's phone number — you look up their name in your contacts, and the phone handles dialing the actual number behind the scenes. DNS does exactly that, except the "contact" is a domain name and the "phone number" is an IP address.

Why DNS Records Are Needed

Knowing that DNS translates names to addresses is only half the picture. The next question is: translates to what, exactly?

A single domain isn't just "one address." A real website needs to answer several different questions at once:

  • Where do I send visitors who type this domain into a browser?
  • Where do I send emails addressed to this domain?
  • Who is allowed to manage this domain's settings?
  • How can a third-party service (like Google Search Console) verify I actually own this domain?

Each of these questions is answered by a different DNS record. A DNS record is a small instruction stored in a domain's configuration, written in a specific format, that tells the internet how to handle one particular kind of request for that domain.

A domain almost never has just one record — it has a small collection of them, each doing a specific job. Let's meet them one at a time.

NS Record: Who's Responsible for This Domain?

Before any other record matters, something has to answer the question: "Where do I even go to look up records for example.com?"

That's what an NS (Name Server) record does. It points to the specific servers that are authoritative for a domain — meaning, those servers hold the master copy of all the other DNS records for that domain.

A real-life comparison: think of NS records as the listing in a master directory that tells you which local post office handles mail for a particular street. Before the mailman can deliver anything, he first needs to know which post office is responsible for that address. NS records are that "which post office" answer for a domain.

When you buy a domain and connect it to a hosting provider or DNS service (like Cloudflare or Route 53), you're typically updating its NS records to point at that provider's name servers.

A Record: Domain → IPv4 Address

This is the record most people picture when they think "DNS." An A Record maps a domain name directly to an IPv4 address — something like 203.0.113.25.

Going back to the phonebook idea: if NS records tell you which post office handles a street, the A record is the actual house address on that street. It's the most direct, literal mapping: "this name = this numeric address, go here."

example.com.    A    203.0.113.25
Enter fullscreen mode Exit fullscreen mode

When someone types example.com into their browser, this is very often the record that ultimately tells the browser which server to connect to.

AAAA Record: Domain → IPv6 Address

The internet originally ran on IPv4 addresses, but there are only so many of those to go around — about 4.3 billion, which sounds like a lot until you count every phone, laptop, server, and smart fridge on Earth. IPv6 was created as a much larger address space to solve that shortage.

An AAAA Record does exactly what an A record does, except it maps a domain to an IPv6 address instead — something like 2001:0db8:85a3::8a2e:0370:7334.

Think of it as having two valid addresses for the same house: an old-style address (IPv4/A record) and a newer-format one (IPv6/AAAA record). Modern networks increasingly prefer IPv6, so many websites maintain both an A and an AAAA record pointing to the same server, just in two different addressing formats.

CNAME Record: One Name Pointing to Another Name

Sometimes you don't want to give out a raw IP address at all — you just want to say "this name is really just another name, go look that one up instead." That's what a CNAME (Canonical Name) Record does.

A CNAME doesn't point to an IP address. It points to another domain name, which then gets resolved on its own (often eventually landing on an A or AAAA record).

A relatable analogy: imagine your friend has moved, and instead of giving everyone their new house address directly, they just say, "Mail addressed to my old house? Forward it to my new name in the system, and look that up instead." A CNAME is that forwarding instruction — one name redirecting to another name.

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

This is incredibly common for things like www.example.com pointing to example.com, or a custom domain pointing to a service like myshop.shopify.com.

A common point of confusion: A record vs. CNAME. The simplest way to remember the difference is what's on the right-hand side of the record. An A record always points to an IP address (a number). A CNAME always points to another domain name (text). One is "go to this address," the other is "go ask this other name what its address is."

MX Record: How Emails Find Your Mail Server

Visiting a website and receiving an email for that domain are two completely separate jobs — and DNS handles them with two completely separate kinds of records. MX (Mail Exchange) Records are dedicated specifically to email routing: they tell the internet which mail server is responsible for accepting email sent to addresses at that domain.

Picture it like this: your house has a street address where guests come to visit (that's your A record), but your mail doesn't get handed directly to you at the door — it goes through a post office that's specifically responsible for sorting and delivering mail for your area. MX records are how the internet finds that post office for your domain.

example.com.    MX    10 mail.example.com.
Enter fullscreen mode Exit fullscreen mode

That number before the mail server name (10 here) is a priority — if a domain lists multiple mail servers, lower numbers are tried first, with others as backups.

Another common point of confusion: NS vs. MX. NS records answer "who manages this domain's DNS settings overall?" MX records answer a much narrower question: "where should email for this domain be delivered?" A domain can have its DNS managed by one company (NS) while its email is hosted entirely somewhere else, like Google Workspace (MX) — they're independent of each other.

TXT Record: Extra Information and Verification

Not every DNS record is about routing traffic somewhere. Sometimes a domain just needs to say something — store a small piece of text that other systems can check. That's the job of a TXT (Text) Record.

TXT records are extremely flexible. The two most common real-world uses are:

  • Domain ownership verification — when you connect a domain to a service like Google Search Console, Vercel, or AWS, they'll often ask you to add a TXT record containing a specific code. This proves you actually control the domain's DNS settings, not just that you're claiming to.
  • Email security — records like SPF and DKIM, which are technically just specially formatted TXT records, help receiving mail servers verify that an email claiming to be from your domain is actually legitimate, cutting down on spoofing and spam.

Think of a TXT record as a sticky note pinned to the front door that says "yes, I really do live here" or "only trust mail that's been stamped this particular way." It's not directing traffic anywhere — it's just providing proof or extra context.

How All These Records Work Together for One Website

Here's where it all clicks into place. A single, fully functioning domain — say, a small business website with email — typically relies on all of these records working as a team:

  1. NS records point to the name servers responsible for managing example.com's DNS settings.
  2. A record maps example.com to the IPv4 address of the web server hosting the site.
  3. AAAA record maps the same domain to an IPv6 address, for visitors on modern networks.
  4. CNAME record makes www.example.com simply forward to example.com, so both versions of the URL work.
  5. MX record tells the internet that email for @example.com should be delivered to a specific mail server (maybe Google Workspace or a custom mail host).
  6. TXT records sit quietly in the background, proving domain ownership to third-party services and helping authenticate outgoing email.

None of these records "compete" with each other — each one answers a different question, and together they form the complete operating instructions for a domain. A browser visit uses the A/AAAA (and possibly CNAME) records. An incoming email uses the MX record. A third-party integration check uses a TXT record. And underneath it all, the NS record made sure everyone was looking in the right place to begin with.

Wrapping Up

DNS can feel intimidating because of all the acronyms, but at its core it's just a structured phonebook with a few specialized entry types: NS says who's in charge, A and AAAA give the literal address, CNAME forwards one name to another, MX routes email, and TXT holds extra proof or instructions. Once you can picture each record's specific job — rather than treating DNS as one big mysterious black box — configuring a domain, debugging a "website not loading" issue, or setting up email for a custom domain becomes a lot less scary.

Next time you register a domain and stare at a confusing DNS dashboard full of records, you'll know exactly what each row is actually doing — and why it's there.


Got a DNS record type you'd like explained next — SRV, CAA, or PTR maybe? Drop a comment below, I read every one.

Top comments (0)