Building a DNS Server from Scratch in Zig! After completing Ziglings, I'm taking on the #codecrafters DNS challenge to push deeper into systems programming. Live and unfiltered.
Well, after grinding some time in the past few days on this project and rewriting a bunch of it, it's finally done. In this short live session, I'm going to give a quick tour of changes and what I've learned so far.
I'm sure it'll be fun, so CHALLENGE ACCEPTED 💪🏼🤓.
Related Playlists:
• Build to Learn: DNS Server in Zig
• Ziglings: Livecoding
Notes:
✅ Session 1: https://sourcery.zone/articles/2025/0...
✅ Session 2: https://sourcery.zone/articles/2025/0...
✅ Session 3: https://sourcery.zone/articles/2025/0...
✅ Session 4: https://sourcery.zone/articles/2025/0...
✅ Session 5: https://sourcery.zone/articles/2025/0...
✅ Session 6, 7, and 8: https://sourcery.zone/articles/2025/0...
✅ Session 9, and 10: https://sourcery.zone/articles/2025/0...
⭐ Sessions 11 to 17: https://sourcery.zone/articles/2025/1...
Reach out and Chat
Matrix: https://matrix.to/#/#sourcery-zone:matrix.org
Timestamps
00:00:00 Stream Warm Up
00:01:16 passed all CodeCrafters tests; recap
00:02:52 extract DNS client into separate interface
00:03:18 chase memory leaks; local vs tester mismatch
00:04:02 add binary-level tests to drive fixes
00:05:03 split multi-question packets; forward individually
00:05:56 `makeQuestion()` builds single-Q request buffer
00:07:04 copy header + question; no allocator
00:07:41 add bounds checks while writing bytes
00:09:14 refactor query path; leaks eliminated
00:10:06 introduce `Transport` interface; UDP impl
00:11:02 guard: require header bytes before parse
00:12:08 fake transport tests for client behavior
00:13:05 `message.zig`: parse/serialize packet model
00:14:09 fix: ensure zero byte after domain labels
00:15:11 add `deinit()` to free nested allocations
00:17:37 leak test with testing allocator
00:19:47 note: Zig fills undefined memory with 0xAA
00:21:02 next: build a usable DNS for my setup
00:22:06 roadmap: more Zig, new challenges soon
#zig #lowlevelprogramming #systemprogramming #coding #codinglive