networkingdnsdevops

DNS Explained

DNS Explained

When you buy a domain, the registrar gives you a control panel full of acronyms — A, AAAA, CNAME, MX, TXT, NS. This post is a practical map of what each one does and when to pick it.

For a deeper dive on A vs CNAME vs ALIAS vs URL redirects, see Understanding DNS Records.


How a lookup works (30-second version)

  1. Your browser asks a recursive resolver (often your ISP or 1.1.1.1) for www.example.com.
  2. The resolver walks the DNS tree — root → .comexample.com — until it finds an authoritative answer.
  3. The record type you configured (A, CNAME, MX, …) tells the resolver what kind of answer to expect.

Record types at a glance

RecordPurpose
AMaps a hostname → IPv4 address
AAAAMaps a hostname → IPv6 address
CNAMEAlias — points one name to another hostname
MXMail exchange — where email for the domain is delivered
TXTArbitrary text — SPF, DKIM, domain verification
NSNameserver — which hosts are authoritative for the zone
SRVService location — port + host for a specific service
URL redirectHTTP redirect (registrar-specific; not standard DNS)

A records (the most common)

Use an A record when you know the IP address and it is stable.

HostPoints toExample use
@IPv4Root domain example.com203.0.113.10
wwwIPv4www.example.com → same or different server
blogIPv4Subdomain → dedicated VM
*IPv4Wildcard — catches undefined subdomains

Example (Namecheap-style panel):

Type   Host   Value
A      @      203.0.113.10
A      www    203.0.113.10
A      blog   198.51.100.5
A      *      203.0.113.99

Rule of thumb: never put a CNAME on the root @ — use A or ALIAS instead.


AAAA records

Same as A, but for IPv6. If your server has a v6 address and you want dual-stack resolution, add matching AAAA records alongside A.


CNAME (alias)

A CNAME says: this name is really that other name. The target must be a hostname, not a raw IP.

Typical pattern:

CNAME   www   example.com.
  • @ (apex) usually cannot be a CNAME on most providers.
  • Do not mix CNAME with other record types on the same name (e.g. MX on www if www is a CNAME).

MX records (email)

MX tells the world which mail servers accept email for your domain. Lower priority number = preferred server.

MX   @   10 mail.example.com.
MX   @   20 backup.example.com.

Some panels show MXE (mail easy) — a simplified single-field MX setup on shared hosting.


TXT records

Used for:

  • SPF — who may send mail as your domain
  • DKIM — cryptographic mail signing
  • Domain verification — Google Workspace, Microsoft 365, etc.

Example SPF:

TXT   @   "v=spf1 include:_spf.google.com ~all"

NS records

NS delegates authority. When you use Cloudflare, AWS Route 53, or another DNS host, you change NS at the registrar to point to their nameservers. They then serve your A/CNAME/MX/TXT records.


URL redirect vs URL frame (registrar extras)

Many registrars (Namecheap, GoDaddy, …) offer non-standard options:

OptionBehaviour
URL redirect (unmasked)Browser shows 301/302 to the target URL — address bar changes
URL frame / maskedContent loaded in a frame — address bar stays on your domain (avoid for SEO)

Prefer a proper A/CNAME + HTTPS setup on real hosting when you can. Redirects are fine for parked domains or simple forwards.


Choosing a record type (decision tree)

Need to point a name to an IP?
  └─ Yes → A (or AAAA for v6)

Need to alias to another hostname?
  └─ Yes → CNAME (not on apex @)

Need email delivery?
  └─ Yes → MX

Need SPF/DKIM/verification string?
  └─ Yes → TXT

Just redirect visitors to another URL?
  └─ URL redirect (registrar) or proper HTTP redirect on your server

References

Enjoyed this post?

Get the next one in your inbox — only when I ship something worth reading.

Newsletter form not configured.

Or follow on Substack for the newsletter.

Comments via GitHub Discussions

Comments not configured. Set GISCUS env vars to enable.