A simple, recursive DNS resolver built from scratch in Rust.
This project implements the DNS protocol as specified in RFC 1035 to resolve domain names by walking the DNS tree from the root servers down to the authoritative name servers. It does not rely on any system or external DNS libraries for the core resolution logic.
- Recursive Resolution: Resolves
A,NS, andCNAMErecords by querying the DNS hierarchy. - Protocol Implementation: All DNS packet construction and parsing is implemented from scratch.
- No External Dependencies: The core logic uses only standard Rust libraries for UDP networking.
- Handles DNS Compression: Correctly parses domain name pointers as specified in the RFC.
-
Clone the repository:
git clone https://github.com/RedlineDevs/dns-resolver.git cd dns-resolver -
Build and run:
cargo run <domain-to-resolve>
If no domain is provided, it defaults to
www.google.com.
$ cargo run github.com
Resolving github.com recursively...
Step 1: Querying root server for com NS records...
Found 13 name servers for com
Step 2: Resolving com name server IPs...
a.gtld-servers.net -> 192.5.6.30
...
Step 3: Querying com name server for github.com NS records...
Found 8 name servers for github.com
Step 4: Resolving github.com name server IPs...
ns-421.awsdns-52.com -> 205.251.193.165
...
Step 5: Querying github.com name server for github.com A record...
Found: github.com -> 140.82.114.4
Final result: github.com -> 140.82.114.4