A DNS resolver built from scratch in Python using only the standard library. Demonstrates low-level DNS packet construction and parsing, UDP communication, modular OOP design, and in-memory caching with TTL.
Layers:
- CLI – handles user input and prints output
- Resolver – orchestrates queries, caching, and network transport
- Packet – encodes and decodes DNS packets
- Transport – sends/receives UDP packets
- Cache – stores responses for performance
- Python 3.9+
- Standard library only
Bash or Zsh
python -m src.main example.com
- DNS packet encoding (DNSHeader, DNSQuestion, DNSRecord)
- DNS packet decoding (DNSHeader, DNSQuestion, DNSRecord)
- Unit tests for encoding and decoding
- Logging setup
- Transport layer (UDP send/receive)
- Iterative resolver (query a known resolver e.g. 8.8.8.8)
- In-memory caching with TTL
- Refactor to recursive resolver (follow referrals from root servers)
- Support multiple record types (A, AAAA, CNAME, MX)
