DNS Records A, AAAA, CNAME, MX, TXT Explained
DNS records connect a domain name to IP addresses and services: A and AAAA point to an IP, CNAME points to another name, MX names the mail server, and TXT stores text data such as SPF and verification strings. Below is each record type, its format and how to check the result.
The main DNS record types
| Type | Purpose | Example value |
|---|---|---|
| A | name → IPv4 | 203.0.113.10 |
| AAAA | name → IPv6 | 2001:db8::1 |
| CNAME | alias → another name | shop.example.com |
| MX | mail server for the domain | mail.example.com |
| TXT | text data | v=spf1 include:… |
| NS | zone delegation | ns1.provider.com |
A and AAAA records
An A record points a domain at the server’s IPv4 address, AAAA at its IPv6 address. This is the foundation of any website.
example.com. 3600 IN A 203.0.113.10
www.example.com. 3600 IN A 203.0.113.10
example.com. 3600 IN AAAA 2001:db8::1
The number 3600 is the TTL in seconds — how long resolvers cache the record. A lower TTL makes changes take effect faster, a higher one reduces load.
CNAME record
A CNAME makes one name an alias of another. It is useful when several subdomains should point at the same host.
blog.example.com. 3600 IN CNAME example.com.
Limitation: a CNAME cannot sit on the domain root (example.com) alongside other records, and cannot be mixed with MX or NS records on the same name.
MX record
MX records define the mail servers for a domain. The number before the name is the priority (lower means higher precedence):
example.com. 3600 IN MX 10 mail.example.com.
example.com. 3600 IN MX 20 backup-mail.example.com.
The mail server itself must have an A record pointing at its IP.
TXT record
A TXT record stores arbitrary text. It is used most often for mail authentication and domain ownership verification:
example.com. 3600 IN TXT "v=spf1 ip4:203.0.113.10 -all"
_dmarc.example.com. 3600 IN TXT "v=DMARC1; p=quarantine; rua=mailto:[email protected]"
How to add the records
- Log in to the DNS control panel at your domain registrar or hosting provider.
- Select the zone for the domain you need.
- Add a record: choose the type, the name (
@for the root), the value and the TTL. - Save and wait for propagation — no longer than the previous TTL, usually minutes, sometimes hours.
Additional record types
Beyond the basics, a few more types come up often enough to be worth knowing:
- NS — names the authoritative name servers for the zone; this is how a domain is delegated to a hosting provider.
- SRV — defines the host and port of a specific service (used by VoIP, XMPP, Minecraft, Active Directory).
- CAA — restricts which certificate authorities may issue certificates for the domain.
- PTR — the reverse record (IP → name); it lives in the IP owner’s zone and matters for mail delivery.
An SRV record example for a service on port 5222:
_xmpp-client._tcp.example.com. 3600 IN SRV 10 5 5222 chat.example.com.
The numbers after SRV are priority, weight, port and target host.
How to verify records
The dig utility (Linux, macOS):
dig example.com A +short
dig example.com MX +short
dig example.com TXT +short
On Windows use nslookup:
nslookup -type=A example.com
nslookup -type=MX example.com
Frequently asked questions
Why doesn’t a record take effect immediately? Because of DNS caching governed by the TTL. Until the old TTL expires, resolvers keep serving the previous value. Lower the TTL in advance of a planned change.
A record or CNAME for www — what is the difference? An A record points www straight at an IP, a CNAME points it at another name such as the domain root. A CNAME is more convenient when the IP may change.
Why do I need an SPF TXT record? It declares which servers may send mail on behalf of your domain, which reduces the chance of your messages landing in spam.
Can I have several A records for one name? Yes. Multiple A records on the same name give simple round-robin — the resolver hands out the addresses in turn.
What is TTL and what value should I pick? TTL is the record’s caching time in seconds. 3600 (one hour) is a safe default; drop it to 300 before a planned change so it propagates quickly.
Launching a site and pointing a domain at your own server? Deploy a Linux VPS in the VPS hosting section, or hand the setup over to server administration.