Loading
0x50Lesson 6 of 7

Resolve names with DNS

Follow the lookup from a name to a network address.

15 min 4-question quiz 1 code exercise
By the end of this lesson you can
  • Describe DNS lookups and cache lifetimes.

The Domain Name System is a distributed, hierarchical naming system. A resolver can answer from its cache or ask DNS servers for records such as A (IPv4) and AAAA (IPv6). A record’s TTL tells caches how long they may reuse the answer. DNS maps names to data; it does not prove that a server is trustworthy.

network_demo.py
1cache = {"learn.example": ("203.0.113.8", 300)}
2name = "learn.example"
3address, ttl = cache[name]
4print(address)
5print(f"cache for at most {ttl} seconds")
Output
203.0.113.8
cache for at most 300 seconds

Resolvers may follow referrals through the DNS hierarchy, and cached answers can make repeated lookups faster. A TTL is a maximum cache lifetime, not a promise that the answer will remain valid for that entire time.

Key takeaways

  • Describe DNS lookups and cache lifetimes.

  • The code examples simulate protocol behavior; they do not send network traffic.

  • Use the layer model to locate where an address, port, or message belongs.

Lesson quiz

4 questions · pass with 3 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.

Practice: model networking concepts

Use small Python programs to model packet, address, and protocol behavior. These exercises run locally in your browser and do not send network traffic.

Exercise 1

Look up a cached name

+25 XP

Read a host name and print its address from the sample DNS cache. Print not found for other names.

  • Known host
  • Unknown host
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Did you like the lesson? 😆👍
Consider a donation to support our work: