This is my Rust implementation of the CodeCrafters Build Your Own DNS Server challenge.
The project is intentionally small, but it covers the core pieces of a DNS server: parsing DNS packets from UDP, decoding compressed question names, encoding DNS responses, forwarding queries to an upstream resolver, and generating mock A-record answers for challenge stages that allow synthetic responses.
- DNS wire-format parsing and serialization without a DNS library.
- Rust ownership around borrowed packet buffers and encoded response buffers.
- Typed errors with
thiserrorand application-level error propagation withanyhow. - A bounded, standard-library worker pool for concurrent UDP request handling.
- Structured logging with
tracing. - Unit tests for packet encoding/decoding, compressed names, response construction, handler behavior, provider behavior, CLI parsing, and worker configuration.
cargo run -- --local-addr 127.0.0.1:2053 --resolver 8.8.8.8:53Optional concurrency settings:
cargo run -- --workers 4 --queue-capacity 128Logging can be controlled with RUST_LOG:
RUST_LOG=debug cargo runcargo test
cargo clippy --all-targets --all-features -- -D warningsThis is a learning project, not a production DNS server. It supports the subset of DNS needed for the CodeCrafters challenge. One challenge-specific behavior is called out in code: when an upstream resolver fails, the handler falls back to synthetic A records because some CodeCrafters stages accept mocked answers.