DNS in Depth
DNS translates names into addresses. It is also one of the most common causes of outages, because changes are cached all over the internet.
How resolution works
- Your computer asks a recursive resolver (your ISP, 1.1.1.1 or 8.8.8.8).
- If it has no cached answer, the resolver asks a root server, which points to the
.comservers. - The
.comservers point to the domain's authoritative nameservers (for example Cloudflare). - The authoritative server gives the answer, and the resolver caches it for the record's TTL.
Record types
| Type | Purpose | Example |
|---|---|---|
| A | name → IPv4 | @ A 203.0.113.10 |
| AAAA | name → IPv6 | @ AAAA 2001:db8::1 |
| CNAME | alias to another name | www CNAME pandadevhub.onrender.com |
| MX | mail servers for the domain | @ MX 10 mx.provider.com |
| TXT | text: verification, SPF, DKIM, DMARC | @ TXT "v=spf1 include:_spf.provider.com ~all" |
| NS | which nameservers are authoritative | set at the registrar |
| CAA | which authorities may issue certificates | @ CAA 0 issue "letsencrypt.org" |
A CNAME cannot sit at the root (@) of a domain alongside other records. Providers solve this with "ALIAS", "ANAME" or "CNAME flattening".
TTL and propagation
TTL is how long resolvers may cache an answer, in seconds. Before a planned migration, lower the TTL to 300 a day ahead, make the change, then raise it again. "DNS propagation" is just caches expiring.
dig: the DNS tool
dig pandadevhub.com # A record
dig +short pandadevhub.com AAAA
dig pandadevhub.com MX
dig TXT _dmarc.pandadevhub.com
dig @1.1.1.1 pandadevhub.com # ask a specific resolver
dig +trace pandadevhub.com # follow the whole chain from the root
dig pandadevhub.com NS
If dig @<authoritative-nameserver> shows the new value but dig @1.1.1.1 shows the old one, you are waiting for caches to expire, not facing a misconfiguration.
Common DNS mistakes
- Editing records at the registrar while the domain actually uses Cloudflare's nameservers (check
NSfirst). - A trailing typo in a CNAME target.
- Two SPF TXT records (there must be only one; merge them).
- Forgetting
wwwor the apex when moving hosts.
Local overrides
/etc/hosts (or C:\Windows\System32\drivers\etc\hosts) overrides DNS on one machine. It is handy for testing a new server before switching DNS, and a classic cause of "it works only on my laptop".
Check yourself
- Why lower a TTL before a migration?
- Which records does email authentication use?
- How do you tell propagation delay from a wrong record?
你的进度只保存在此浏览器中。
提交审核(10 积分)