DNS

DNS Records Explained: A, CNAME, MX and TXT

What the common DNS record types do, one rule about CNAME records that catches people out, and how to change DNS safely.

Autobaselli · 2 min read

DNS maps names to the information needed to reach services. You manage it with records at your DNS provider. This guide covers the types most small sites use.

Diagram: a browser asks DNS where a site is, gets an address, then requests the page from the web host.
The simplified path from typing an address to loading a page. Real lookups also use caching resolvers, which is why DNS changes can take time to appear.

A and AAAA records

An A record points a name to an IPv4 address. An AAAA record does the same for an IPv6 address. They are typically used to point a domain to a server.

CNAME records

A CNAME makes one name an alias of another name. It is common for pointing "www" at a hosting provider's address. The key rule comes from the DNS standard: if a CNAME exists at a name, no other data should exist at that name (RFC 1034, section 3.6.2; RFC 2181, section 10.1 makes this stricter, allowing only DNSSEC-related records). The root of your domain, also called the apex, already holds records such as NS and SOA, and often MX and TXT, so a plain CNAME at the apex is not allowed. Some providers offer proprietary workarounds with names like ALIAS or "CNAME flattening". Whether yours does depends on the provider, so check its documentation.

Diagram comparing allowed records, such as a CNAME at www, with a CNAME at the root that conflicts with MX records.
Based on RFC 1034 and RFC 2181. Some DNS providers add their own ALIAS or flattening feature for the root, which is a provider feature, not part of the standard.

MX records

MX records say which mail servers receive email for the domain. Changing the website's DNS must not remove them or your email can stop.

TXT records

TXT records hold text. Services use them to verify domain ownership and to publish email authentication settings such as SPF.

Nameservers

The nameservers for your domain decide where your DNS records live. If you switch nameservers, the records at the old provider stop applying. Anything not copied to the new provider, such as email, verification or subdomain records, stops working. The DNS change check on this site helps you list what needs copying.

Pointing a domain at a host

  1. Open the hosting provider's custom-domain instructions and note the exact record type, name and value it asks for.
  2. Look at your current records first and write them down.
  3. Add or change only the records the host asks for.
  4. Allow time for caches to expire, which depends on each record's TTL.
  5. Test the site over HTTPS, with and without www.

Sources