Home › Networking › DNS

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

  1. Your computer asks a resolver (usually run by your ISP, or something like 1.1.1.1) for example.com.
  2. If the resolver does not have it cached, it asks a root server, which replies: “I do not know, but ask the .com servers.”
  3. The .com servers reply: “ask the name servers for example.com.”
  4. Those authoritative name servers finally answer with the IP address.
  5. 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

RecordHolds
AAn IPv4 address.
AAAAAn IPv6 address.
CNAMEAn alias pointing at another name.
MXWhere email for the domain should go.
TXTArbitrary text (used for verification, SPF, DKIM).
NSWhich 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.

Keep reading