This is a starting point for Java solutions to the "Build Your Own DNS server" Challenge.
I built a DNS server that's capable of parsing and creating DNS packets, responding to DNS queries, handling various record types and doing recursive resolve. Along the way I learnt about the DNS protocol, DNS packet format, root servers, authoritative servers, forwarding servers, various record types (A, AAAA, CNAME, etc) and more.
Note: If you're viewing this repo on GitHub, head over to codecrafters.io to try the challenge.
Run the below command on your terminal to clone the repository locally on your machine.
git clone https://github.com/10adnan75/dns-server.gitRun the below commmands on your terminal to initialize a repository.
git init
git remote add origin <your-repository-url>
git add .
git commit -am "your-commit-message" # any msg
git push origin masterThe entry point for your your_program.sh implementation is in
src/main/java/Main.java.
Server: Open a terminal, and compile and run your java code using the below commands:
cd /dns-server
/target/classes Main --resolver <address>Client: Open another terminal, run the following command:
dig @127.0.0.1 -p 2053 +noedns <SLD.domain@TLD>Note: This section is for testing and beyond.
- Ensure you have
mvninstalled locally - Run
./your_program.shto run your program, which is implemented insrc/main/java/Main.java. - Commit your changes and run
git push origin masterto push your code to Github. Test output will be streamed to your terminal.

