Skip to content

shricastic/dns-server-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DNS Server in Rust (from Scratch)

A lightweight, async DNS server written in Rust, built from scratch using tokio. It parses raw DNS packets manually and supports:

βœ… DNS query parsing
βœ… UDP socket handling
βœ… Hardcoded A record replies
βœ… Forwarding to Remote DNS server 8.8.8.8 when record not found
βœ… In-memory response caching


πŸ“Έ Architecture

Architecture


πŸ” DNS Flow

Flow


πŸ› οΈ Features

  • Built with tokio and pure std for learning and performance
  • Handles DNS over UDP (port 5354)
  • Caches responses using an in-memory RwLock<HashMap<..>>
  • Manually parses DNS headers and questions β€” no magic libraries
  • Forwards queries to Google DNS (8.8.8.8) if not in cache

πŸš€ Run It

cargo run

About

dns server from scratch in rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages