Himanshu SharmaSoftware engineer
Let’s talk

How the Web Works · Lesson 5 of 15

DNS explained: how a name becomes an address

See how the Domain Name System turns names into IP addresses, what resolvers, name servers and record types do, and how TTL and caching affect changes.

14 minFinding the serverUpdated 14 November 2026

Awaiting technical review. This lesson is readable but not yet listed in search engines.

By the end of this lessonExplain the steps of a DNS lookup, name the common record types, read dig output, and predict why a DNS change can take time to appear.

A phone book for the whole internet

Computers connect using IP addresses, but people remember names. The Domain Name System (DNS) is the service that translates one into the other. RFC 1034 and RFC 1035 are the original specifications. By the end of this lesson you will understand each hop of a lookup, be able to read real dig output, and know why changing DNS settings is never instant.

DNS is not one big computer. It is a distributed database: thousands of servers each hold a small piece, and they point to each other. That design lets it handle enormous numbers of questions without one central bottleneck.

Names are read right to left

Take www.example.com. (the final dot, usually hidden, is the root). Read it from the right:

  • . is the root, the top of the tree.
  • com is a top-level domain (TLD).
  • example is a domain registered under com.
  • www is a subdomain that the owner of example.com can create freely.

Each level is managed by a different party, and each one knows who looks after the level below.

Who does what in a lookup

Four roles appear:

  1. Stub resolver, built into your operating system, which asks for an answer on behalf of your browser.
  2. Recursive resolver, a service (often your network provider's, or a public one you configure) that does the searching and keeps a cache.
  3. Name servers, which hold the records. Root servers know where each TLD's servers are, TLD servers know where each domain's servers are, and the domain's own authoritative servers give the final answer.
  4. The domain owner, who decides what goes into the authoritative records.

When nothing is cached, the recursive resolver asks a root server, which points to the com servers. Those point to the domain's authoritative servers, which answer. The resolver hands the answer to you and saves a copy.

Watch it happen

dig +trace follows that path itself. This is trimmed output captured on 2026-11 for example.com, a name reserved for documentation. Yours will differ in the numbers and the servers:

text
com.			172800	IN	NS	b.gtld-servers.net.
com.			172800	IN	NS	c.gtld-servers.net.
example.com.		172800	IN	NS	hera.ns.cloudflare.com.
example.com.		172800	IN	NS	elliott.ns.cloudflare.com.
;; Received 359 bytes from 192.5.6.30#53(a.gtld-servers.net) in 144 ms
example.com.		300	IN	A	104.20.23.154
example.com.		300	IN	A	172.66.147.243
;; Received 72 bytes from 2606:4700:58::a29f:2ce4#53(elliott.ns.cloudflare.com) in 14 ms

The first block is the root's referral: "for com, ask these servers." The second shows a com server saying "for example.com, ask these name servers." The last lines are the authoritative answer. Notice the port, 53, which is the standard DNS port, and that the referral records carry a long TTL while the final address has a short one.

An ordinary lookup is shorter:

text
;; QUESTION SECTION:
;example.com.			IN	A

;; ANSWER SECTION:
example.com.		248	IN	A	172.66.147.243
example.com.		248	IN	A	104.20.23.154

;; Query time: 19 msec

Record types you will actually use

Type Holds Example use
A IPv4 address Point shop.example at a server
AAAA IPv6 address Same, for IPv6
CNAME Another name Make www an alias of the main name
MX Mail server Say where email for the domain goes
TXT Free text Ownership checks and email-sending policies
NS Name server Say who answers for the domain

Real answers for example.com captured in 2026-11 included two NS records pointing at Cloudflare's servers, and TXT records containing "v=spf1 -all", an email policy meaning "no mail is sent from this domain". A single MX 0 . record, as seen there, is the way a domain says it accepts no mail. A CNAME cannot sit beside other records on the same name, which is why a bare domain usually uses A records instead.

TTL and why changes take time

Every record carries a TTL (time to live), in seconds. It tells resolvers how long they may keep an answer. In the outputs above, the number in the second column is the remaining TTL, which is why it counts down between lookups: one run showed 278, another 248 for the same record.

Consequences for you:

  • If you change an A record, anyone whose resolver cached the old one keeps seeing the old address until the TTL runs out.
  • Before a planned move, site owners often lower the TTL a day or so ahead, then raise it afterwards. That is a common practice, not a rule.
  • Browsers and operating systems may cache as well, so "I changed it but still see the old site" is usually a cache, not a failure.

Where DNS fits in the bigger picture

Your computer asks DNS for the address, then connects with it. DNS does not carry the page. It only tells your browser where to go. For the full sequence see What happens when you open a website. For who owns and controls the records, continue to Domain names and registrars.

Common mistakes

  • Blaming the server when the real issue is a DNS change that has not spread yet.
  • Putting a CNAME on the bare domain alongside other records.
  • Forgetting the dot in tools: example.com. with a final dot is the complete name.
  • Deleting email-related records (MX, TXT) while moving the website.
  • Testing with only one resolver. Compare more than one, or ask an authoritative server directly with dig @name-server name.

Exercise

  1. Run dig example.com A, wait a minute, and run it again. What changed in the answer?
  2. Run dig example.com NS and dig example.com TXT. Which companies' names appear, and what do the TXT records look like?
  3. A shop owner changes the address of shop.example. The old record has a TTL of 3600. What is the longest a cached resolver might keep the old answer?
Show one possible answer
  1. The TTL number is lower on the second run, because the resolver is counting down its cached copy. The addresses themselves usually stay the same.
  2. The NS records name the servers that answer for the domain. TXT records vary; they are plain quoted text.
  3. Up to 3600 seconds, which is one hour, from the moment it was cached. A resolver that cached it just before the change may serve the old address for nearly the full hour.

Key points

  • DNS is a worldwide, distributed database that maps names to data such as IP addresses.
  • Your device asks a resolver, which asks root, top-level-domain and authoritative name servers in turn if it has no saved answer.
  • Records have types: A and AAAA hold addresses, CNAME is an alias, MX handles mail, TXT holds text and NS names the name servers.
  • Each answer has a TTL, a time in seconds that others may keep it, which is why changes spread gradually.

Check yourself

1. Which record type holds an IPv4 address for a name?
2. What is a resolver?
3. A record has a TTL of 300. What does that mean?
4. You change a site's A record, but a friend still sees the old site for a while. What is the most likely reason?
5. Which record says that www.shop.example is another name for shop.example?