A DNS server implementation in C++ that handles recursive resolution, various record types, and packet parsing. Built as a learning project to get deeper into networking and systems programming.
- parses DNS packets from raw bytes
- handles A, AAAA, CNAME, MX, NS, and other common record types
- performs recursive resolution against root and authoritative servers
- responds to DNS queries with the appropriate answers This was my way of understanding how DNS actually works under the hood. Reading RFC 1035 and implementing the protocol piece by piece taught me more about networking than any textbook did.
I wanted to build something in C++ that wasn't a game or a graphics demo. DNS is a good fit because:
- packet parsing requires careful memory handling
- recursive resolution involves a lot of async-style state management
- it forces you to think about buffers, sockets, and protocol details
- DNS packet structure and wire format
- how recursive resolvers chase down answers
- the difference between authoritative and caching servers
- handling UDP/TCP sockets in a systems language
- why DNS caching matters and how TTLs work
# with cmake
mkdir build && cd build
cmake ..
make
./dns_server
# or use the provided script
./your_program.shThe server binds to port 53 and responds to queries.
src/
main.cpp - entry point and server loop
dns/ - packet parsing and record types
resolver/ - recursive resolution logic
cache/ - basic caching implementation
This is a learning project, not production software. It doesn't handle:
- DNSSEC validation
- zone transfers
- high-performance concurrency
- complex record types But it does answer basic queries and demonstrates the core DNS concepts.