EmilHernvall/dnsguide
EmilHernvall/dnsguide has 4,695 GitHub stars and 289 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 13:59 UTC. Last push 2025-04-28.
A guide to writing a DNS Server from scratch in Rust
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalBuilding a DNS server in Rust
The internet has a rich conceptual foundation, with many exciting ideas that enable it to function as we know it. One of the really cool ones is DNS. Before it was invented, everyone on the internet - which admittedly wasn't that many at that stage - relied on a shared file called HOSTS.TXT, maintained by the Stanford Research Institute. This file was synchronized manually through FTP, and as the number of hosts grew, so did the rate of change and the unfeasibility of the system. In 1983, Paul Mockapetris set out to find a long term solution to the problem and went on to design and implement DNS. It's a testament to his genius that his creation has been able to scale from a few thousand computers to the Internet as we know it today.
With the combined goal of gaining a deep understanding of DNS, of doing something interesting with Rust, and of scratching some of my own itches, I originally set out to implement my own DNS server. This document is not a truthful chronicle of that journey, but rather an idealized version of it, without all the detours I ended up taking. We'll gradually implement a full DNS server, starting from first principles.
- Chapter 1 - The DNS protocol
- Chapter 2 - Building a stub resolver
- Chapter 3 - Adding more Record Types
- Chapter 4 - Baby's first DNS server
- Chapter 5 - Recursive Resolve
Samples
Each chapter has a corresponding sample which contains the full code up to
that point in the guide, named sample1.rs through sample5.rs. These can be
run using, for first chapter, cargo run --example sample1.
Revision History
- June 2020 - Fixed a security vulnerability in
read_qnamewhich allowed for a malicious packet to trigger an infinite loop. Modernized the code to conform to current rust practices, and fixed various ugly inefficiencies. - July 2016 - Initial version
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
561,027 starspublic-apis/public-apis
A collective list of free APIs
497,267 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
443,236 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,202 stars