DNS
Computers talk in numbers, people remember names. DNS is the phone book that connects the two.
When you type example.com, your computer has no idea where that is. It needs an IP address like 93.184.216.34. DNS (the Domain Name System) is the distributed database that does the lookup.
The lookup, step by step
- Your computer asks a resolver (usually run by your ISP, or something like
1.1.1.1) forexample.com. - If the resolver does not have it cached, it asks a root server, which replies: “I do not know, but ask the
.comservers.” - The
.comservers reply: “ask the name servers forexample.com.” - Those authoritative name servers finally answer with the IP address.
- The resolver caches the answer and hands it back to you.
It looks like a lot of hops, but caching means most lookups are answered instantly from memory somewhere along the chain.
Record types
| Record | Holds |
|---|---|
A | An IPv4 address. |
AAAA | An IPv6 address. |
CNAME | An alias pointing at another name. |
MX | Where email for the domain should go. |
TXT | Arbitrary text (used for verification, SPF, DKIM). |
NS | Which name servers are authoritative. |
TTL and caching
Every record has a TTL (time to live) in seconds. It tells resolvers how long they may cache the answer. A low TTL (say 300) means changes propagate quickly but there are more lookups; a high TTL (86400) is efficient but a change can take a day to be seen everywhere.
Looking it up yourself
$ dig example.com +short
93.184.216.34
$ dig example.com MX +short
0 .
$ nslookup example.com
Why a page can “work for me but not for you”: often it is a stale DNS cache. Changing a record and waiting out the old TTL — or flushing your resolver — fixes it.