RustDNS: Writing a Recursive DNS Resolver in Rust, Byte by Byte
Описание и применение
RustDNS – минимальный рекурсивный резолвер DNS, написанный на Rust без внешних зависимостей. Он слушает UDP‑порт 2053, последовательно запрашивает корневые, TLD‑ и авторитетные серверы и возвращает ответы клиенту.
Задача
Build a minimal recursive DNS resolver in Rust that can resolve domain names without external dependencies.
Результат
The resolver successfully resolves google.com by querying root, TLD, and authoritative servers, returning multiple A records.
Рабочий процесс
- Clone the repository from GitHub
- Run
cargo run --releaseto start the resolver on 0.0.0.0:2053 - Use
dig @127.0.0.1 -p 2053 google.comto query the resolver - Observe the resolver printing each lookup step and the final answers
- Optionally use the provided 12‑line Python client to send a query
Доказательства
RustDNS is a recursive DNS resolver written in plain Rust with zero dependencies, just std::net::UdpSocket and a 512-byte array.
Port 2053 instead of 53 is deliberate: ports below 1024 need root on Linux, and this way you don't have to sudo a learning project.
Received query: DnsQuestion { name: "google.com", qtype: A } attempting lookup of A google.com with ns 198.41.0.4 attempting lookup of A google.com with ns 192.41.162.30 attempting lookup of A google.com with ns 216.239.34.10 Answer: A { domain: "google.com", addr: 142.250.29.100, ttl: 300 }
- Дата записи: 2026-10-06T16:40:51.727Z