DNS (Domain Name System) translates names like example.com into the IP addresses computers use. Every time you launch a website on a new server, set up email, verify a domain with a service or move hosting providers, you edit DNS records. A wrong record means a site that does not load, email that bounces, or a certificate that cannot be issued. This guide explains each record type with practical examples.
Where DNS records live
Your domain’s nameservers (NS records, set at your registrar) decide which DNS provider is authoritative — your registrar, Cloudflare, or another DNS host. You edit records at that provider. Changing records anywhere else has no effect.
Check which nameservers a domain uses:
dig NS example.com +short
The record types
A — name to IPv4 address
The most important record. Points a name to your server’s IPv4 address.
| Name | Type | Value |
|---|---|---|
@ (the domain itself) |
A | 203.0.113.10 |
www |
A | 203.0.113.10 |
@ means the bare domain (example.com). You can have several A records for one name (simple load distribution), but for a single server, use one.
AAAA — name to IPv6 address
The same as A, for IPv6. Only add an AAAA record if your server actually has a working IPv6 address and your web server listens on it — a wrong AAAA record makes the site fail for visitors with IPv6, which can be hard to diagnose.
CNAME — alias to another name
Points a name to another name, not an IP:
| Name | Type | Value |
|---|---|---|
www |
CNAME | example.com. |
shop |
CNAME | shops.myplatform.com. |
Rules:
- A CNAME cannot coexist with other records for the same name.
- The bare domain (
@) cannot be a CNAME under the DNS standard (some providers offer “CNAME flattening” or ALIAS records as a workaround). - Do not point MX or NS records at a CNAME.
MX — mail servers for the domain
Tells other mail servers where to deliver email for @example.com:
| Name | Type | Priority | Value |
|---|---|---|---|
@ |
MX | 10 | mail.example.com. |
@ |
MX | 20 | backup-mx.example.net. |
Lower priority numbers are tried first. The MX target must be a hostname with an A record — never an IP address, never a CNAME. If you use a hosted email provider, use the MX values they give you.
TXT — text for verification and email security
TXT records hold arbitrary text, used for:
- Domain verification (Google Search Console, Microsoft 365, Bing Webmaster Tools and many more).
- SPF — which servers may send email for the domain:
v=spf1 mx a ip4:203.0.113.10 -all - DKIM — public keys for email signatures (on a name like
default._domainkey). - DMARC — email authentication policy (on
_dmarc).
Email authentication is covered in detail in SPF, DKIM and DMARC.
NS — nameservers
Delegate a domain or subdomain to nameservers. At the top level they are set at your registrar. You can also delegate a subdomain to another provider (e.g. dev.example.com NS ns1.otherdns.com.).
PTR — reverse DNS (IP to name)
PTR records map an IP address back to a name. They are not set in your domain’s DNS zone, but by whoever controls the IP address — your hosting provider. They matter mostly for mail servers. See reverse DNS explained.
CAA — which CAs may issue certificates
example.com. CAA 0 issue "letsencrypt.org"
Only the listed certificate authorities may issue certificates for the domain. If you add CAA, include every CA you use, or certificate issuance will fail.
SRV — service locations
Used by some protocols (SIP, XMPP, Microsoft 365, some games) to point to a host and port: _sip._tcp.example.com SRV 10 5 5060 sip.example.com.
TTL and “propagation”
Every record has a TTL (time to live) in seconds — how long resolvers may cache it. With TTL 3600, a changed record can take up to an hour to be seen everywhere, because resolvers keep the old answer until it expires. That delay is what people call “DNS propagation”.
Before a planned migration:
- Lower the TTL to 300 (5 minutes) at least one old-TTL period in advance.
- Make the change.
- Raise the TTL again afterwards (3600 or more).
This is part of the process in migrating a website to a new server.
Typical setups
Website on your own server
@ A 203.0.113.10
www CNAME example.com.
Website on your server, email with a hosted provider
@ A 203.0.113.10
www A 203.0.113.10
@ MX 10 (provider's MX hosts)
@ TXT "v=spf1 include:(provider's SPF) -all"
The website and email are independent: moving the website changes only the A records.
Self-hosted mail server
mail A 203.0.113.20
@ MX 10 mail.example.com.
@ TXT "v=spf1 mx -all"
default._domainkey TXT "v=DKIM1; k=rsa; p=..."
_dmarc TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"
Plus a PTR record for 203.0.113.20 → mail.example.com, set with your hosting provider. See running a mail server with Mailcow.
Checking DNS
dig (Linux/macOS; package dnsutils or bind-utils):
dig example.com A +short
dig www.example.com +short
dig example.com MX +short
dig example.com TXT +short
dig -x 203.0.113.10 +short # reverse (PTR)
dig @1.1.1.1 example.com A +short # ask a specific resolver
dig @ns1.yourdnshost.com example.com A # ask the authoritative server directly
Windows:
nslookup example.com
nslookup -type=MX example.com
nslookup example.com 1.1.1.1
Asking the authoritative nameserver shows what you configured; asking a public resolver shows what visitors currently see (possibly a cached old value).
To check from many locations at once — including resolvers inside mainland China — use an online DNS propagation checker.
Troubleshooting
| Symptom | Check |
|---|---|
| Domain shows the old site | TTL not expired yet; check with dig @authoritative-ns |
| Changes have no effect at all | Editing DNS at the wrong provider (check NS records) |
www works, bare domain does not (or vice versa) |
Missing A record for @ or www |
| Let’s Encrypt fails | A/AAAA pointing elsewhere, or a CAA record excluding Let’s Encrypt |
| Email bounces | MX missing or pointing to an IP/CNAME; SPF/DKIM problems |
| Site fails only for some users | Wrong AAAA record (IPv6 users) |