How to point a domain to your app: a DNS records checklist

2026-11-20来源 dev.toEnglish

When a domain does not resolve to your app, the cause is usually in DNS, not in the application code. This checklist covers the records that put a site and mail on a name you already own: A, AAAA, CNAME, MX, and the TXT records used for SPF, DKIM, and DMARC.

Decide where you will edit DNS
Pick one place to hold the zone, and keep every record there.

Keep the current nameservers and add records in that DNS host (the registrar's DNS, Cloudflare, Route 53, or similar).
Or change the nameservers at the registrar to those from your host or DNS provider, then add the records in the new system.
If you change nameservers, the old zone stops being used once resolvers follow the new NS set. Recreate web, mail, and verification records in the new zone before you switch. Use only the nameservers, IPv4, IPv6, or CNAME target your host or platform publishes.

A and AAAA records
An A record maps a name to an IPv4 address (RFC 1035, section 3.4.1). An AAAA record maps a name to an IPv6 address (RFC 3596, section 2.1). Use these at the zone apex (example.com) when your host publishes a stable server IP.

Create an A record for @ or example.com with the IPv4 address. Add a matching AAAA only if the host actually serves IPv6. An AAAA that points at a dead address will break IPv6 clients.

example.com. 300 IN A 203.0.113.10
example.com. 300 IN AAAA 2001:db8::10
www.example.com. 300 IN A 203.0.113.10

The addresses above are documentation examples from RFC 5737 and RFC 3849, not a real host.

CNAME records, and why the apex is different
A CNAME says that one name is an alias of another canonical name (RFC 1034, section 3.6.2). Pointing www at a hostname your platform controls is a correct use of CNAME:

www.example.com. 300 IN CNAME app.example-host.example.

A name with a CNAME cannot have other data. RFC 1034 says that if a CNAME is present at a node, "no other data should be present." RFC 2181, section 10.1, allows DNSSEC-related records on an alias, and nothing else, so a CNAME cannot share example.com with A, AAAA, MX, or TXT.

The apex already has mandatory SOA and NS records (RFC 2181, section 6.1), so a standard CNAME at example.com is rejected. If your platform only offers a hostname for the bare domain, put the CNAME on www, use A/AAAA on the apex, and redirect the apex to www over HTTP. Some DNS hosts offer ALIAS, ANAME, or CNAME flattening, which answer with A or AAAA records. Those are vendor features, not a standard record type in the RFCs cited here.

MX records
An MX record names a mail server for the domain and gives it a preference value. Lower values are tried first (RFC 1035, section 3.3.9; RFC 5321, section 5.1).

example.com. 300 IN MX 10 mx1.mail-host.example.
example.com. 300 IN MX 20 mx2.mail-host.example.

The MX target must not be an alias. RFC 2181, section 10.3, says it must have address records (A or AAAA today), never a CNAME. RFC 5321 says a CNAME target "lies outside the scope of this Standard." Point MX at the hostname your mail provider specifies, and confirm that name has its own A or AAAA records. Skip MX until you have a provider.

TXT records for SPF, DKIM, and DMARC
A TXT record holds text (RFC 1035, section 3.3.14). Mail authentication uses TXT records at specific names.

SPF authorizes which hosts may send mail for a domain. Publish a single TXT record at the apex that begins with v=spf1 (RFC 7208). More than one SPF record is a permerror (RFC 7208, section 4.5), so merge a new sender into the existing record.

example.com. 300 IN TXT "v=spf1 include:mail-host.example -all"

DKIM publishes a public key so receivers can verify a message signature. RFC 6376, section 3.6.2.1, stores keys under _domainkey. If the signature's s= selector is s1 and d= is example.com, the lookup is s1._domainkey.example.com, usually as a TXT record. Some providers ask for a CNAME at that selector name instead. Use exactly one of those, not both.

DMARC publishes a policy for the visible From domain as a TXT record at _dmarc.example.com (RFC 7489, section 6.1):

_dmarc.example.com. 300 IN TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"

p=none requests reports without asking receivers to quarantine or reject mail. Tighten the policy only after reports show that legitimate mail passes SPF or DKIM alignment.

Order of operations and how to verify
Collect IPs or CNAME targets, MX hosts, the SPF include, the DKIM selector, and a DMARC report address.
If you are moving nameservers, prepare every record first.
Publish apex A/AAAA (or the provider's apex alias feature) and a www CNAME or A/AAAA.
Add MX only if you will use mail, with targets that resolve to A or AAAA.
Add one SPF TXT at the apex, the DKIM record at selector._domainkey, and a DMARC TXT at _dmarc.
Wait for the previous TTL to expire. If the old A record had a 3,600-second TTL, caches may serve it for up to that long. There is no fixed "worldwide 24-hour" delay.
Then complete TLS and query the records:

dig A example.com +short
dig AAAA example.com +short
dig CNAME www.example.com +short
dig MX example.com +short
dig TXT example.com +short
dig TXT _dmarc.example.com +short
dig TXT s1._domainkey.example.com +short

Replace s1 with your DKIM selector. If you changed nameservers, also check dig NS example.com +short. After the TTL window, query a public resolver (dig @8.8.8.8 A example.com). If the records are right and the browser still shows an old site or a certificate error, check the app, the HTTP redirect, and the certificate.

Sources
RFC 1034, section 3.6.2 (CNAME; no other data at the same name)
RFC 1035, sections 3.3.9 (MX), 3.3.14 (TXT), and 3.4.1 (A)
RFC 2181, sections 6.1, 10.1, and 10.3
RFC 3596, section 2.1 (AAAA)
RFC 5321, section 5.1 (SMTP target host)
RFC 7208 (SPF), RFC 6376 section 3.6.2 (DKIM), RFC 7489 section 6.1 (DMARC)
Documentation address ranges: RFC 5737, RFC 3849
Check DNS after you register a name on Domains and WebCAA.

原文:https://www.a8q9.cn/en/article/how-to-point-a-domain-to-your-app-a-dns-records-checklist-3962d0.html

相关文章