A Golang DNS implementation developed for learning purpose.
The command below will build the program and create the executable file dns
.
mkdir bin
go build -o bin/dns
The decode command prints the content of a dns message. The message may be provided from the stdin or from a file.
dns --path ./message
cat ./message | dns --stdin
There are many ways you can get a DNS message, but a quick way to do so is using dig and nc.
In a terminal, run the nc command:
nc -u -l -p 5553 > ./message
This will make nc to listen for a udp datagram on port 5553 and to write the datagram content to a file called message.
In another terminal, run the dig command:
dig +retry=0 -p 5553 @127.0.0.1 +noedns www.google.com
This instructs dig to send a DNS query to a server in localhost port 5553 (or nc command).