THE PROBLEM
People remember names more easily than numeric IP addresses, but routers need IP addresses to deliver packets.
THE NAIVE APPROACH
Keeping a hand-written list of every name and address would quickly become stale and difficult to share.
THE KEY INSIGHT
DNS delegates naming data across a hierarchy and returns typed records such as A and AAAA.
WHERE YOU MEET IT
- • Opening a website by domain name
- • Email servers locating mail exchangers
- • Apps discovering service endpoints
ANALOGY / HISTORY
A distributed phone directory: ask for a name and receive the number.
Context: Centralized HOSTS.TXT files could not scale with a growing network.
client → server · QUERY_READY
Client builds a query
The client asks for the IPv4 address associated with example.com. The DNS header is 12 bytes, followed by the encoded question.
Local DNS wire-format query encoder. No request is sent.
The dots are not transmitted. Each label is prefixed by its byte length and the name ends with a zero byte.
QNAME is a sequence of length-prefixed labels. QTYPE 0x0001 asks for an A record and QCLASS 0x0001 means Internet.