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.comis a top-level domain (TLD).exampleis a domain registered undercom.wwwis a subdomain that the owner ofexample.comcan 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:
- Stub resolver, built into your operating system, which asks for an answer on behalf of your browser.
- Recursive resolver, a service (often your network provider's, or a public one you configure) that does the searching and keeps a cache.
- 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.
- 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:
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 msThe 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:
;; 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 msecRecord 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
Arecord, 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
- Run
dig example.com A, wait a minute, and run it again. What changed in the answer? - Run
dig example.com NSanddig example.com TXT. Which companies' names appear, and what do the TXT records look like? - 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
- 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.
- The
NSrecords name the servers that answer for the domain. TXT records vary; they are plain quoted text. - 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.