Skip to content

RedlineDevs/dns-resolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust CI

DNS Resolver in Rust

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.

Features

  • Recursive Resolution: Resolves A, NS, and CNAME records 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.

How to Run

  1. Clone the repository:

    git clone https://github.com/RedlineDevs/dns-resolver.git
    cd dns-resolver
  2. Build and run:

    cargo run <domain-to-resolve>

    If no domain is provided, it defaults to www.google.com.

Example Output

$ 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

About

A recursive DNS resolver built from scratch in Rust, implementing RFC 1035.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages