Full Byte Developer.

How DNS works

DNS maps names people type to IP addresses machines route; a recursive resolver walks root, TLD, then authority.

Published here , updated · 5 sources

DNS is the Internet's phonebook: it translates human-readable names into IP addresses so clients can reach hosts [1]. After name resolution finishes, protocols such as HTTP then fetch the page bytes [1]. Related: what is HTTP and what is a server.

Quick start (under a minute)

Open a terminal. Ask your system resolver for an address:

bash
dig +noall +answer example.com A

If dig is missing, try getent hosts example.com on Linux or nslookup example.com elsewhere. You want a line that ends in an IPv4 or IPv6 address. That line is DNS doing its job; nothing in that command fetches a web page.

See one resolver answer on this host

Observed on this draft host (DiG 9.18.39, Ubuntu 24.04, 2026-12-03):

text
example.com.		148	IN	A	104.20.23.154
example.com.		148	IN	A	172.66.147.243

The trailing 148 is TTL in seconds: roughly how long this resolver may treat the answer as fresh [1] [3]. The two A rows mean two IPv4 addresses for the same name (load balancing or anycast). Absolute IPs change over time; treat them as samples, not constants.

RFC 1034 describes DNS as a distributed database with a hierarchical name space [2]. RFC 1035 carries the on-wire message format stub resolvers and authoritative servers use [3]. For teaching, Cloudflare's eight-step walkthrough (nothing cached) is still the clearest story [1].

Walk the delegation chain (teaching picture)

When no cache helps, a recursive resolver does the walking. The diagram follows Cloudflare's mental model; arrows are referrals and final answers, not HTTP [1].

Caching at the browser, the OS, or the recursive resolver can skip steps when a prior answer is still valid [1]. That is why "flush DNS" sometimes fixes a migration and sometimes does nothing: you may still be hitting an upstream TTL.

Name the four jobs without blurring them

RoleJob (Cloudflare Learning) [1]
Recursive resolverWorks on behalf of the client; follows referrals; may cache
Root nameserverEntry to the tree; refers toward a TLD
TLD nameserverOwns a public suffix (.com, .net, .org, ...)
Authoritative nameserverHolds the zone; gives the final answer for names in that zone

Stub resolver is the piece in your OS that talks to the recursive resolver. People say "DNS server" when they mean any of the four; be specific in incident writeups.

On the wire, classic DNS queries are usually small UDP datagrams to port 53 [3]. Large responses or middleboxes may force TCP fallback; that detail matters when a firewall blocks one transport. DNS over HTTPS (DoH) and DNS over TLS (DoT) wrap the same logical questions in HTTPS or TLS for privacy and captive-portal resistance [1]. The names still resolve to addresses; only the carriage changes.

Authoritative answers are typed records [2] [3]. A and AAAA map a name to IPv4 or IPv6. CNAME is an alias to another name (another lookup). MX points mail. TXT carries arbitrary strings (SPF, DKIM, verification tokens). Teaching HTTPS later still starts here: no routable address, no TCP, no TLS.

Keep DNS separate from "the site is down"

Symptoms overlap. A stale A record, a fat-fingered CNAME, or NXDOMAIN looks like a dead website in the browser. HTTP status codes only appear after DNS and TCP succeed (what is a server).

Split the debug path:

  1. Resolution: does the name return the address you expect?
  2. TCP: does the port open?
  3. TLS: does the certificate match the hostname?
  4. HTTP: what status and body come back?

Jumping to cookie clears or CDN purges before step 1 wastes time.

Point your laptop at a known recursive resolver

When you suspect ISP DNS filtering or poisoning, repeat the same question against a public recursive resolver and compare answers [1]:

bash
dig @1.1.1.1 +noall +answer example.com A
dig @8.8.8.8 +noall +answer example.com A

If both agree but your default resolver does not, the bug is local policy or cache, not the authoritative zone. If authoritative data recently changed, query the authoritative NS directly only when you know which nameservers own the zone (WHOIS or parent delegation), not as a daily habit.

Negative answers matter too. NXDOMAIN means the name does not exist in the tree you queried. NOERROR with an empty answer section can mean a name exists but the record type you asked for is absent. Those are different failure modes for deploy scripts that assume an A record exists.

TTL and negative caching in plain words

TTL is a per-record hint in seconds [3]. A resolver may cache shorter if policy requires, but it must not cache longer than the TTL in the answer. Short TTL (60 to 300) speeds cutovers at the cost of more queries. Long TTL (hours to days) reduces load and improves resilience but slows incident rollback.

SOA records carry additional timing fields for zone transfers; for readers of this page, the user-visible knob is still TTL on the records you publish [2]. When you lower TTL before a migration, wait at least one old TTL window before you treat the new target as universal.

Mistakes that waste a week

Thinking DNS "hosts the website." DNS stores records about names. HTTP servers (or other services) host bytes. DNS only tells clients where to knock.

Confusing registrar, DNS host, and nameserver. You buy a domain at a registrar. The registrar points delegation to nameservers. Those nameservers are authoritative for your zone. Changing web hosts often means editing records at the DNS host, not at the registrar, unless you also move nameserver glue.

One global instant update. TTL and resolver caches mean propagation is time bounded, not immediate. Plan TTL down before moves; measure with dig +trace or dig @authoritative when you have permission.

Treating ping as DNS proof. ping uses DNS then ICMP. Blocked ICMP looks like "down" when HTTP is fine. Prefer dig or curl -v for layered checks.

Private DNS overrides the public tree without configuration. Your laptop uses resolver settings (DHCP, VPN, /etc/resolv.conf, DoH in the browser). A corporate split-horizon zone can return different answers inside the office. Document which resolver you tested.

Keep the dig output from a broken deploy; it beats guessing whether HTTP or DNS failed. Once you have the expected address, the next layer is what is HTTP status codes and headers, and what is a server for the process that listens after TCP connects. Encrypted sites still begin with the same name lookup.

Send this to the friend who blames the app before checking what DNS returned.

Three dark spheres in a row with short teal hops, a large teal arc skipping the middle sphere, and an orange arrow from the last sphere to a white vertical disc, no people.
Cached answers skip hops; a cold lookup walks the delegation tree.

Keep this guide

By Full Byte Developer

Filed under Dev explainers

Questions about this guide

What problem does DNS solve?

Humans remember example.com. Routers need numeric addresses. DNS is the distributed lookup that returns A or AAAA records (and other types) so TCP can open a socket. Cloudflare Learning and RFC 1034 both frame it as a name-to-address translation layer, not as HTTP itself.

What are the four server roles in a typical lookup?

Recursive resolver (starts the hunt for your stub resolver), root nameserver (refers toward a TLD), TLD nameserver (owns .com, .org, etc.), authoritative nameserver (holds the zone file for the name). Caching at any hop can skip earlier steps when a TTL has not expired.

Is DNS the same as HTTP?

No. DNS answers where to connect. HTTP (or another application protocol) runs after you have an address and an open transport. A 404 is HTTP; NXDOMAIN or a wrong A record is DNS.

Why do I still see an old IP after I changed DNS?

Every answer carries a TTL (time to live) in seconds. Resolvers and browsers cache until that TTL ends. Lower TTL before a migration, then raise it again when stable. Stale cache is normal behavior, not random DNS breakage.

Sources

Next in this stack