Good morning! This is a toy for playing with DNS. It can do a few things:
- Run an DNS echo server (that can be queried using
dig
) - Read DNS packets stored on disk
This is a playground to improve my understanding of DNS at the packet level, so I can implement an embedded nameserver in another project. I'm making it public in case it's useful for others :)
On the roadmap:
- DNS server that HTTP clients can resolve against
- i.e. a (local) authoritative nameserver
- TCP support
- Tests
$ cargo run --bin cli -- read examples/question_packet
$ ...
First, listen on a port using netcat:
$ nc -u -l 3000 > question_packet
Then, in a seperate terminal, make a DNS request to it using dig
:
$ dig +retry=0 -p 3000 @127.0.0.1 +noedns example.com
When this completes, you can stop the netcat server and parse the datagram:
$ cargo run --bin cli -- read question_packet
$ ...
This will receive UDP packets, parse and print them, and then echo them back to the caller.
$ cargo run --bin cli -- serve 127.0.0.1:3000
$ dig +retry=0 -p 3000 @127.0.0.1 +noedns example.com
/cli
contains the commandline interface and UDP server/core
contains the DNS packet parsing logic