Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 06 · From Scratch · DNS Server · with code: Go · about 11 min to read

Play it as a journeyTutor comes with a plan

Build Your Own DNS Server

DNS Resolution
DNS Resolution · Open board

The concierge story: your laptop asks one helper for an address and the helper walks the directory for you. That helper is a DNS server. This build writes one.

Before you start. This series builds a small DNS server, the program that turns a name like www.example.test into the number a computer needs to reach it. You need two ideas from the Networking track, refreshed here. DNS is the internet’s name directory: you ask it a name and it answers with an address (DNS Resolution). The question and the answer travel as short fixed-format packets, and DNS on the wire takes a real one apart byte by byte. Write the telegram yourself wrote the question side in Python. This build writes the side that answers. If Go is new to you, Enough Go to read these builds is an optional read first.

Code: teaching/code/from-scratch/dns/. One Go module, six stages, each a program you can run: go run ./01-udp up to go run ./06-forward. Each stage folder holds the files the earlier stages needed plus one or two new ones. Only the Go standard library, and the DNS bytes are built by hand: no DNS package. The real dig is the tester.

Lesson 38 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • November 1983: one file, and it stopped scaling
  • A DNS server is a function from bytes to bytes
  • Why the build listens on port 8053
  • The six stages
  • What this build leaves out, on purpose
  • Go, as you go

Terms it explains: name server, UDP, 8053, Record types beyond `A`.

Lab

You changed the address. How long until the world stops sending people to the old one?

Set Seconds the concierge keeps the note to 300, press Add next question through the run, and watch the stranded count in The tally.

Open The TTL dial

Review From Scratch