Lion Cipher Lab

Write a DNS resolver from scratch (build and parse DNS packets over UDP; resolve from the root)

Why it matters

Name resolution is the first thing that happens in almost every connection on the internet, and it is the layer most security people treat as a black box: you type a hostname, a number comes back, you move on. But DNS is also one of the most attacked layers there is -- cache poisoning, spoofed responses, subdomain takeovers, tunneling, and NXDOMAIN abuse all live here -- and you cannot reason about any of those attacks if you have never seen what a DNS packet actually is. This lab fixes that by making you BUILD the resolver instead of reading about it. When you have assembled the 12-byte…

What you'll learn

Steps in this lab

  1. What DNS is, and the three kinds of server that answer
  2. The wire format: the 12-byte header and the question section
  3. Encode the QNAME and build the query packet by hand
  4. Send it over UDP and get the raw bytes back
  5. The hard part: parse the answer AND implement name compression (0xC0)
  6. The failure modes: the TC truncation bit, TCP fallback, and EDNS0
  7. Climb the tree: iterative resolution from the root, following NS + glue
  8. Cross-check with dig +trace, and prove you match the real thing
  9. The judgment: why you built this, and what to run in production

Open the full interactive lab →