This repository contains the code for a DNS server implemented in Rust, as part of the tutorial Building a DNS Server in Rust . The tutorial covers:
- Understanding DNS requests and responses.
- Handling UDP packets in Rust.
- Parsing and constructing DNS packets.
- Implementing decompression of DNS packets.
- Forwarding DNS queries to resolvers.
For a step-by-step guide, check out the full tutorial: Building a DNS Server in Rust: Part 1 of 2
Ensure you have Rust installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shgit clone https://github.com/Rust-Trends/dns-server-tutorial.git
cd dns-server-tutorialGoto to the step you want to explore, e.g. step1, and start the DNS server on port 1053:
cd step1
cargo runTo test your server, open another terminal and run:
dig @localhost -p 1053 www.rust-trends.comFeel free to open issues or submit pull requests to improve the project!
π License: MIT