All articles
169 articles · updated weekly See our Tools
All articles
Tutorials

DNS records explained: A, AAAA, CNAME and MX

What the A, AAAA, CNAME and MX DNS records do, with practical examples and the most common mistakes when configuring a domain.

DNS records explained: A, AAAA, CNAME and MX
COVER · Tutorials

You bought the domain, pointed it at your hosting, and half an hour later the site still won't open. Or worse: the site loads but the email never arrives, or only works "sometimes." The culprit almost always lives in the same place — your domain's DNS records table. Four record types account for most of the trouble first-time domain owners hit: A, AAAA, CNAME and MX. Understanding what each one does (and what it does not do) saves hours of trial and error in the hosting panel.

DNS in one sentence

DNS is the internet's phone book: it translates a human-readable name (example.com) into the numeric address machines use to find each other. When you type a domain, your computer asks a DNS server "what's the address for this?", and the answer comes from one of these records. If you want the bigger picture — from the click in the browser to the loaded page — read How the internet works, from DNS to HTTP; here the focus is practical: what to put on each line of the DNS zone.

Think of the DNS zone as a spreadsheet. Each row has a name (the subdomain, or @ for the root), a type (A, AAAA, CNAME, MX...), a value (where it points), and a TTL (how long the answer may be cached).

A record — the name becomes an IPv4

The A record (for Address) is the most fundamental. It links a domain name to an IPv4 address, in the 192.0.2.10 format. It's what tells the browser which server to fetch your site from.

@      A   192.0.2.10
www    A   192.0.2.10

The first line resolves the root (example.com), the second resolves www.example.com. You can have several A records for the same name pointing to different IPs — a simple form of load balancing (round-robin), with the resolver picking among them.

AAAA record — the IPv6 version

The AAAA does exactly the same job as the A, but for IPv6 addresses, in the 2001:db8::1 format. The four-letter name is an inside joke: an IPv6 address is four times larger than an IPv4 one (128 bits versus 32).

@      AAAA   2001:db8::1
www    AAAA   2001:db8::1

You don't choose between A and AAAA — you publish both when the server supports IPv6. The client decides which to use. Skipping AAAA breaks nothing for most users today, but networks that prefer IPv6 may resolve a bit slower without it.

CNAME record — an alias to another name

The CNAME (Canonical Name) does not point to an IP — it points to another name. It's an alias. When someone requests shop.example.com and a CNAME points it to shops.platform.com, the resolver follows the chain until it reaches an A/AAAA record at the final destination.

shop    CNAME   shops.platform.com.
blog    CNAME   myblog.blog-service.com.

CNAME shines when the target is managed by a third party (CDN, e-commerce platform, GitHub Pages). If the provider swaps the IP, you change nothing — the alias still points to the name, and the name resolves on its own.

Two rules that trip everyone up:

  1. A name with a CNAME cannot have any other record at the same name. No A, MX or TXT coexisting with a CNAME in the same entry.
  2. Because of rule 1, the domain root (@) cannot be a CNAME — the root is required to carry SOA and NS records, and CNAME forbids coexistence. To point the root at an external service, use A/AAAA with the provider's IPs, or the proprietary ALIAS/ANAME types when your DNS offers them.

MX record — where email goes

The MX (Mail Exchange) has nothing to do with the website. It declares which servers receive email for your domain. Each MX carries a server name and a priority (lower number = higher preference).

@   MX   10   mx1.email-provider.com.
@   MX   20   mx2.email-provider.com.

Here mx1 (priority 10) is tried first; if it fails, mx2 (priority 20) takes over. Two important details: an MX value must be a name, never an IP; and that name needs its own A/AAAA record for mail to work. MX only routes delivery — authentication and anti-spam are handled by TXT records (SPF, DKIM, DMARC), which are a separate topic.

The most common mistakes in practice

  • Mixing a CNAME with other records. The number-one cause of "the email vanished": someone creates a CNAME at the root, and it silently cancels the MX that was sitting there.
  • Pointing MX at an IP. Some panels even accept it, but delivery breaks. MX always points to a name.
  • Forgetting the trailing dot on records that want an FQDN (example.com.). Without the dot, some providers append the domain again and you end up with example.com.example.com.
  • Expecting changes to be instant. The old TTL is still cached. If the TTL was 24h, it can take up to a day for everyone to see the new value. Lower the TTL before a planned migration.
  • Confusing www with the root. They're two different names. Configuring only www leaves example.com (without www) down.

To check where an A or AAAA record actually points — and who owns that IP — you can use our IP address info tool and confirm the destination before you blame DNS.

Frequently asked questions

What's the difference between an A record and a CNAME?

The A points a name directly at a numeric IP address. The CNAME points a name to another name, which in turn resolves to an IP. Use A when you know the IP; use CNAME when you want to follow a third-party-managed target without worrying about IP changes.

Can I use a CNAME on the domain root?

Not under the standard. The root needs SOA and NS records, and a CNAME can't coexist with any other record. To point the root at an external service, use A/AAAA records with the supplied IPs, or the ALIAS/ANAME types if your DNS provider supports them.

Do I need AAAA if I already have A?

It's not mandatory, but it's recommended when your server has IPv6. You publish both and the client chooses. Without AAAA, IPv6-first networks may resolve slightly slower.

Why did I change DNS and it still hasn't updated?

Because of TTL and caching. Resolvers hold the old answer for the duration of the TTL. If it was set to 24 hours, full propagation can take up to a day. Lowering the TTL ahead of time shortens that window.

What to take from this guide

A, AAAA, CNAME and MX cover almost everything a domain needs: A and AAAA place the name in IP space (IPv4 and IPv6), CNAME creates aliases that follow managed targets, and MX routes email. Memorize the two CNAME constraints — nothing coexists with it, and it can't live at the root — and remember MX points to a name, never an IP. With that, most "the site won't open" and "the email never arrives" stops being a mystery and becomes one wrong line in a table, easy to find and fix.

RD
Author
Rafael Duarte
Backend developer with a background in fintech and B2B SaaS — worked on teams that scaled APIs from zero to millions of requests. Carries enough production scars to hold strong opinions on tools, patterns and architecture decisions. Not an academic: he read the UUID RFC when he had to choose between v4 and v7 for a write-heavy table.
View profile