How DNS works, briefly
DNS, the Domain Name System, is the internet's directory. It turns names like example.com into the information computers need: an IP address to connect to, the servers that accept email, the keys that verify signatures, and more.
Two kinds of DNS server are involved:
- Authoritative nameservers hold the records for a domain. They're run by your DNS host: your registrar, Cloudflare, your web host or similar. The domain's
NSrecords say which servers they are. - Resolvers do the looking up for everyone else: your internet provider's resolver, your company's, or public ones like Google Public DNS and Cloudflare's 1.1.1.1. They ask the authoritative servers and keep a cached copy of the answer for a while.
Everything a domain publishes lives in its zone: a set of records, each with a name, a type, a time to live (TTL) and some data.
name TTL type data
example.com. 3600 A 203.0.113.10
www.example.com. 3600 CNAME example.com.
example.com. 3600 MX 10 mail.example.com.
The TTL is how many seconds resolvers may cache the answer. It's why changes aren't instant; see DNS TTL and propagation explained. In most DNS control panels you type only the part before your domain (www), or @ for the domain itself.
A and AAAA: addresses
An A record maps a name to an IPv4 address; an AAAA record maps it to an IPv6 address.
example.com. A 203.0.113.10
example.com. AAAA 2001:db8::10
- A name can have several A or AAAA records. Clients pick one, which spreads load and gives some redundancy.
- Publish AAAA only if the server really answers over IPv6. A broken AAAA record causes slow or failed connections for visitors on IPv6 networks.
Look them up with the A lookup and AAAA lookup.
CNAME: an alias
A CNAME record says "this name is another name for that one". The resolver follows it and looks up the target's records instead.
www.example.com. CNAME example.com.
shop.example.com. CNAME shops.ecommerce-platform.example.
CNAMEs are how most hosted services work: you point a subdomain at the service, and the service can change its addresses without you touching DNS. Two rules cause most CNAME problems:
- A CNAME can't share its name with any other record. If
shop.example.comis a CNAME, it can't also have an MX or TXT record. - So the domain itself (the "apex",
example.com) can't be a CNAME, because it must have SOA and NS records. Several DNS hosts offer a workaround under names like CNAME flattening, ALIAS or ANAME: they look up the target themselves and publish its addresses as A and AAAA records.
A CNAME pointing at a service you've stopped using can be dangerous: if someone else claims that name at the service, they control your subdomain. The Dangling CNAMEs check looks for these.
MX: where email goes
MX records name the servers that accept email for the domain, each with a preference number. Senders try the lowest number first.
example.com. MX 10 mx1.example.com.
example.com. MX 20 mx2.example.com.
- An MX record must point to a hostname that has its own A or AAAA record. It must not point to a CNAME (RFC 2181), and it shouldn't be an IP address (RFC 5321).
- A domain that accepts no email can say so with a single "null MX" record,
MX 0 ., defined in RFC 7505. It must be the only MX record.
See the MX lookup for more, and moving email to a new provider for changing them safely.
TXT: text for other systems
TXT records hold text. DNS itself doesn't interpret them; other systems do. Most of what you'll publish as TXT:
| Purpose | Name | Starts with |
|---|---|---|
| SPF | the domain | v=spf1 |
| DKIM key | selector._domainkey | v=DKIM1 |
| DMARC | _dmarc | v=DMARC1 |
| MTA-STS | _mta-sts | v=STSv1 |
| Domain verification | the domain or a named subdomain | a token from the service, such as google-site-verification=… |
A single string inside a TXT record can be at most 255 characters. Longer values, like 2048-bit DKIM keys, are split into several strings within the same record, which receivers join back together. Many DNS hosts do the splitting for you.
A domain can have many TXT records, but only one may be an SPF record. See SPF, DKIM and DMARC explained.
NS: who answers for the domain
NS records list the authoritative nameservers.
example.com. NS ns1.dnshost.example.
example.com. NS ns2.dnshost.example.
They exist in two places: in your own zone, and in the parent zone (for example.com, that's .com), where your registrar puts them when you set the domain's nameservers. That second copy, the delegation, is what sends resolvers to your DNS host. The two should match. Changing nameservers at your registrar is the slowest DNS change of all, because the parent's copy is cached for a long time.
Use at least two nameservers, ideally on separate networks. The NS lookup and Nameserver Check show whether yours agree.
SOA: the zone's settings
Every zone has exactly one SOA (start of authority) record, at the apex:
example.com. SOA ns1.dnshost.example. hostmaster.example.com. (
2026113001 ; serial
7200 ; refresh
3600 ; retry
1209600 ; expire
3600 ) ; minimum
- Primary nameserver and contact: the contact is an email address with the
@written as a dot (hostmaster.example.commeans[email protected]). - Serial: a version number that must increase with every change, so secondary nameservers know to copy the new zone. Many hosts use the date plus a counter.
- Refresh, retry, expire: how secondary nameservers keep their copy up to date.
- Minimum: today, together with the SOA record's own TTL, this sets how long resolvers may cache a "no such name" answer (negative caching, RFC 2308).
Most hosted DNS services manage the SOA record for you. The SOA lookup shows it and checks the timers.
CAA: which certificate authorities may issue
CAA records list the certificate authorities allowed to issue TLS certificates for the domain. Authorities must check them before issuing.
example.com. CAA 0 issue "letsencrypt.org"
example.com. CAA 0 issuewild ";"
example.com. CAA 0 iodef "mailto:[email protected]"
issueallows an authority to issue certificates.issuewildcontrols wildcard certificates and takes precedence overissuefor them; an empty value (";") allows none. The rules are in RFC 8659.iodefgives an address for reports about refused requests.- No CAA records means any authority may issue. If you add CAA, include every authority you use, including those behind your CDN or hosting provider, or renewals will fail.
Check yours with the CAA lookup.
SRV: where a service runs
SRV records tell clients which host and port provide a service. The name says which service and protocol:
_sip._tcp.example.com. SRV 10 60 5060 sip1.example.com.
; priority weight port target
Lower priority is tried first; among equal priorities, weight spreads the load. SRV records are used by protocols such as SIP, XMPP and some Microsoft services. Look them up with the SRV lookup, using the full name including the service and protocol.
PTR: reverse DNS
A PTR record works the other way round: it maps an IP address back to a name. It lives in a special zone, in-addr.arpa for IPv4, with the address's four numbers in reverse order, and ip6.arpa for IPv6, written one hexadecimal digit at a time, also reversed:
10.113.0.203.in-addr.arpa. PTR mail.example.com.
PTR records are controlled by whoever owns the IP address, usually your hosting or internet provider, not your DNS host. They matter most for mail servers: receivers expect the sending IP's PTR name to resolve back to the same IP. Check with the reverse DNS lookup.
Wildcards
A record whose name starts with * answers for any name that doesn't otherwise exist at that level:
*.example.com. A 203.0.113.10
Here anything.example.com resolves to 203.0.113.10, but a name that has records of its own, like www.example.com, doesn't use the wildcard. Wildcards are handy for hosting platforms, but they can hide mistakes, so use them deliberately.
Frequently asked questions
What's the difference between an A record and a CNAME?
An A record gives an IP address directly. A CNAME points to another name, and the resolver then looks up that name's records. Use a CNAME when a service gives you a hostname to point at, and an A record when you have an IP address.
Can I have an MX record and a CNAME on the same name?
No. A name with a CNAME can't have any other records. If you need email on a name, it can't be a CNAME.
Why can't I find my record with a lookup tool?
Check the exact name: many DNS panels add your domain automatically, so entering the full name creates www.example.com.example.com. Also check that the domain's nameservers are the ones you're editing, with an NS lookup.
How many nameservers should a domain have?
At least two, and preferably on different networks, so the domain stays reachable if one fails. Hosted DNS providers normally give you two to four.
What TTL should I use?
There's no single right value. An hour (3600 seconds) is a common default; lower it to a few minutes before planned changes and raise it again afterwards. See DNS TTL and propagation explained.