Resolve names with DNS
Follow the lookup from a name to a network address.
- Describe how a resolver walks the DNS hierarchy.
- Predict how caching and TTLs change the work a lookup takes.
- Choose the right DNS record type for a job.
You remember names, but packets need addresses. The Domain Name System connects the two, and it does so without a central database. It's a worldwide system that answers trillions of questions a day because no single server has to know everything.
A tree of delegation
Names are read from right to left. Each level delegates to the one below it, so the root servers don't know where www.learn.example is. They only know who runs example., and that server only knows who runs learn.example.
The resolver does the walking
Your device doesn't do this itself. It asks a recursive resolver, usually run by your provider or a public service such as 1.1.1.1. The resolver asks the root, follows the referrals down to the authoritative server that holds the answer, and returns it to you.
The resolver then caches everything it learned. Each record carries a TTL, the number of seconds it may be reused. Referrals are cached as well, which is why looking up a second name in the same domain is cheap.
Try it
Up to 15 XPRun a caching resolver
Try this sequence and predict the query count each time:
- Look up
www.learn.exampleon a cold cache. - Look it up again.
- Look up
docs.learn.example. The answer isn't cached, but something useful is. - Wait 1 hour, then repeat the first lookup. Which entries survived?
The clock only moves when you wait, so you can compare TTLs in the cache table.
Empty. Every lookup starts at the root.
- Queries sent so far
- 0
More than addresses
DNS stores several kinds of record. These are the ones you'll see most:
Try it
Up to 15 XPMatch the job to the record type
You're setting up a domain. Pick the record type for each job.
“Point learn.example at 203.0.113.8”
“Point learn.example at 2001:db8::8”
“Make www.learn.example an alias of learn.example”
“Say which server receives email for learn.example”
“Prove you own the domain to a cloud provider”
To see real answers, use dig on macOS and Linux, or nslookup on Windows. The number after the name is the remaining TTL in seconds:
$ dig +noall +answer www.learn.example
www.learn.example. 300 IN A 203.0.113.8You can watch a cache at work. Ask a resolver the same question twice, 40 seconds apart, and the TTL counts down, because the second answer came from memory.
1$ dig +noall +answer www.learn.example
2www.learn.example. 300 IN A 203.0.113.8
3
4$ dig +noall +answer www.learn.example
5www.learn.example. 260 IN A 203.0.113.8Try it
Up to 15 XPRead dig output
dig is the tool for asking DNS questions directly. Click the line that answers each question.
Which line holds the address you asked for?
Key takeaways
DNS is a delegated tree, and each level only knows who to ask next.
A recursive resolver walks the tree and caches what it learns.
A TTL limits how long an answer can be reused, so it's a trade-off between speed and freshness.
Lesson quiz
7 questions · pass with 5 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…