{"canonical_url":"https://engineer.company/glossary/dns/","content_markdown":"# DNS\n\n## What it is\n\nDNS, the Domain Name System, is the distributed directory the internet consults\nbefore almost anything else happens. A program holding a name such as\n`example.com` asks it for the address to connect to, and the same system\nanswers a handful of other questions about that name: which servers accept its\nmail, which text its owner has published, which servers are in charge of it.\n\nThe directory is a tree read from right to left. At the top sits the root,\nbelow it top-level domains such as `.com` or `.dk`, below those the domains\npeople register, and below those any subdomains their owners create. No single\nserver holds the tree. Each level hands responsibility for the next one down to\nnamed servers, and the part of the tree that one set of servers answers for is\ncalled a zone. Whoever controls a zone decides what its names resolve to.\n\nTwo kinds of server do the work. Authoritative servers hold a zone and answer\nfor it with the final word. Recursive resolvers, run by internet providers,\ncompanies or public services, do the walking on a client's behalf: they ask a\nroot server where `.com` lives, ask `.com` where `example.com` lives, ask that\ndomain's servers for the record, and hand the answer back. Your operating\nsystem runs only a small stub resolver that passes the question to a recursive\none and waits.\n\nThe answers are typed records, and a zone file is the classic way to write\nthem down:\n\n```text\n$ORIGIN example.com.\n$TTL 3600\n@     IN  SOA    ns1.example.net. hostmaster.example.com. (\n                 2026101701 7200 900 1209600 300 )\n@     IN  NS     ns1.example.net.\n@     IN  A      192.0.2.10\n@     IN  AAAA   2001:db8::10\nwww   IN  CNAME  example.com.\n@     IN  MX     10 mail.example.net.\n@     IN  TXT    \"v=spf1 include:_spf.example.net -all\"\n```\n\n`A` and `AAAA` give IPv4 and IPv6 addresses. `CNAME` makes one name an alias for\nanother. `MX` names the server that receives mail, and `TXT` carries free text,\nwhich in practice means mail-authentication policies and proofs that someone\ncontrols the domain. `NS` and `SOA` describe the zone itself.\n\nEvery record carries a time to live, here 3,600 seconds, and that number is the\nkey to how DNS behaves. A resolver that has fetched an answer may keep reusing\nit until its TTL runs out, without asking again. The result is a system that\nanswers most lookups from a cache close to the client and keeps answering when\nan authoritative server is briefly unreachable, at the price that nobody can\nforce the world to forget an old answer early.\n\n## Why it matters\n\nEvery connection to a named service starts with a lookup. When DNS is wrong,\nthe servers can be perfectly healthy and the site, the API and the mail still\nlook down, because nothing reaches them. When DNS is right, nobody notices it,\nwhich is why it tends to be the least documented part of a system.\n\nDNS is also where control over a domain is exercised and proved. Mail\nproviders read SPF, DKIM and DMARC policies from `TXT` records to decide\nwhether a message claiming to come from your domain is genuine, so a wrong or\nmissing record sends real mail to spam. Certificate authorities and hosted\nservices ask for a record with a specific value as proof that you own the name.\nAnyone who can edit the zone can redirect the site, intercept the mail and\nobtain certificates for the domain, which makes access to the DNS account as\nsensitive as access to the servers.\n\nCaching shapes every change. What people call propagation is really thousands\nof resolvers each waiting for their own copy to expire. The way to move a site\nwith little disruption is to lower the TTL a day or so ahead, wait for the old\nTTL to pass, make the change, and raise the TTL again once it has settled.\n\nClassic DNS travels in plain text, and neither the answers nor the questions\nare private. DNSSEC lets a resolver check that an answer really came from the\nzone's owner and was not altered, and by its own specification it adds no\nconfidentiality. Encrypted transports such as DNS over HTTPS hide the questions\nfrom the network path, while the resolver at the other end still sees every name\nasked for. Choosing a resolver is choosing who gets that list.\n\n## What it looks like in practice\n\nThe company's own zone shows the most common starting point and a way out of\nit. It held\n[about twenty records, kept in a provider's web console](/portfolio/reconciled-a-20-record-dns-zone-as-code/),\ncovering the web presence, a git subdomain, two personal redirects, mail routed\nthrough a hosted mailbox provider, a transactional sending domain and the\nauthentication records for both. In a console, the current state is whatever\nthe last person to click left behind. The zone is now data in a repository:\nlive records, application records, transport-policy records and a separate list\nof records due for removal. One play reconciles that declaration against the\nprovider's API. Two more entry points sit behind explicit opt-in tags, an audit\nthat reports the difference without changing anything and an export that writes\nthe zone in the standard zone-file format, so that something other than the\nrepository can read it. The audit is the part used most, because knowing the\ndifference is more often what is wanted than closing it.\n\nThe same provider has a deliberately narrow job. The site's credits page\nexplains that\n[Cloudflare answers DNS for the site and nothing else](/credits/), with no proxy\nin front, and it prints the server's address outright, since DNS already hands\nthat address to anyone who asks.\n\nReading DNS also belongs to the routine description of the estate. Among\n[seven read-only reporting roles that render the live host into Markdown](/portfolio/built-7-read-only-host-reporting-roles/)\nis a provider inventory that reads DNS alongside two cloud APIs and a\ndedicated-server API, under the rule that no report prints a number its run did\nnot measure.\n\n## Where it goes wrong\n\nDNS failures are often delayed, cached or split, so the same name works for one\nperson and fails for another. These are the ones that recur.\n\nA change refuses to land. Someone edits a record with a TTL of a day and expects\nthe new address to take effect at once, but resolvers that cached the old\nanswer keep serving it until their copy expires. A quieter version catches new\nnames: if a name was looked up before its record existed, the negative answer\nis cached too, for as long as the zone's `SOA` allows (RFC 2308). Lower TTLs\nbefore planned changes, and create records before anything asks for them.\n\nAn alias sits where it cannot. RFC 1034 says that a name holding a `CNAME` may\nhold no other data. The bare domain, `example.com` itself, always holds `SOA`\nand `NS` records, so a standards-following zone cannot make the apex an alias,\nand a `CNAME` on a subdomain that also needs `MX` or `TXT` records breaks the\nsame rule. Providers offer flattened or `ALIAS` records as their own workaround;\neach behaves a little differently, so read what yours actually serves.\n\nMail authentication tips over. Every `include` in an SPF record causes DNS\nlookups, and RFC 7208 caps the total at ten. Adding one more newsletter or\nticketing service can push the record past the limit, and receivers then treat\nthe policy as a permanent error, so the mail it was meant to authenticate is\njudged without it. Count the lookups whenever a sender is added.\n\nA record outlives its target. A subdomain points by `CNAME` at a cloud storage\nbucket or a hosted app that has since been deleted. If the provider lets anyone\nclaim that resource name, a stranger can claim it and serve their own content\nunder your subdomain, with your domain's reputation attached. Remove the record\nin the same change that removes what it points to.\n\nThe zone lives only in a console. There is no history, no review and no\ndiff, so an accidental deletion of the `MX` record is discovered when mail\nstops arriving, and the previous value has to be reconstructed from memory.\nExporting the zone regularly, or better, declaring it as code, gives every\nchange a record and a way back.\n\n## Further reading\n\n- [RFC 1035: Domain Names, Implementation and Specification](https://www.rfc-editor.org/rfc/rfc1035)\n  — record formats, the zone-file syntax and the wire protocol.\n- [RFC 1034: Domain Names, Concepts and Facilities](https://www.rfc-editor.org/rfc/rfc1034)\n  — the tree, zones, delegation and how resolvers walk them.\n- [RFC 9499: DNS Terminology](https://www.rfc-editor.org/rfc/rfc9499) — careful\n  definitions of the words this page uses.\n- [RFC 2308: Negative Caching of DNS Queries](https://www.rfc-editor.org/rfc/rfc2308)\n  — how long a resolver may remember that a name does not exist.\n- [RFC 4033: DNS Security Introduction and Requirements](https://www.rfc-editor.org/rfc/rfc4033)\n  — what DNSSEC protects, and what it leaves alone.\n- [RFC 8484: DNS Queries over HTTPS](https://www.rfc-editor.org/rfc/rfc8484) —\n  carrying lookups inside ordinary encrypted web traffic.\n\n\u003chttps://engineer.company/glossary/dns/\u003e\n","date_modified":"2026-10-20T21:59:50Z","description":"How DNS turns a name into an address, why records and TTLs decide how fast a change lands, and the zone mistakes that break mail and sites.","formats":{"gemtext":"https://engineer.company/glossary/dns/index.gmi","gopher":"https://engineer.company/glossary/dns/gophermap","html":"https://engineer.company/glossary/dns/","json":"https://engineer.company/glossary/dns/index.json","markdown":"https://engineer.company/glossary/dns/index.md","pdf":"https://engineer.company/glossary/dns/index.pdf"},"kind":"page","language":"en","title":"What is DNS?","url":"https://engineer.company/glossary/dns/","version":1}