A low-level DNS resolver being built from scratch in C, focusing on manual packet construction, parsing, and protocol-level understanding of networking.
This project is in early development.
At the moment, it focuses on:
- Raw packet structure definitions (Ethernet, IP, UDP, DNS)
- Manual parsing of IP headers
- DNS query packet construction
- Endianness handling and byte-level manipulation
This is not yet a fully functional recursive resolver.
A fully working recursive DNS resolver that:
- Sends DNS queries directly to root servers
- Performs iterative resolution (root → TLD → authoritative)
- Parses DNS responses manually
- Caches results for efficiency
- Handles multiple query types (A, AAAA, CNAME, etc.)
- Packet Structures
- Ethernet (eth)
- IPv4 (ip, ip_details)
- UDP (udp)
- DNS header + question section
All structures are manually defined using packed memory layout.
- Constructs DNS query manually (e.g., google.com)
- Builds question section byte-by-byte
- Sets query type (A) and class (IN)
- Custom byte-order conversion:
conv16()conv32()
- Runtime endianness detection
-
Define raw buffer
-
Cast buffer into protocol structures
-
Extract header fields manually
-
Construct DNS query name (google.com) in wire format:
6 google 3 com 0
-
Append DNS question tail