This repository contains the code to build a DNS server from scratch. The DNS server is containerized using Docker for easy setup and deployment.
The DNS server is deployed and running on AWS EC2 at: http://13.233.151.85:9000/
Here's a demo of the DNS server in action:
If you are a newbie to DNS learn what is DNS How it Works
See the Types of DNS Query go through
See the Classes used in DNS Query go through
- Docker installed on your machine. You can download Docker from here. -- Or
- You can Run it into your local machine directly but there might be some issue of firewall or port so its better to run it on docker
First, clone the repository to your local machine:
git clone https://github.com/yourusername/dns-server.git
cd dns-server
MONGO_URI=YOUR-MONOGO-URI
Build the Docker image:
docker build -t dns-server .
Run the Docker container:
- DNS server run's on port 53 by default!
docker run -d -p 53:53 dns-server
You can verify that the DNS server is running by using the dig command run this command on docker container terminal:
dig @localhost example.com
1. Log in to your AWS Management Console.
2. Navigate to the EC2 Dashboard.
3. Click on "Launch Instance".
4. Choose an Amazon Machine Image (AMI). We recommend using an Ubuntu Server AMI.
5 .Choose an instance type. A t2.micro instance should be sufficient for testing purposes.
6 .Configure instance details as needed.
7. Add storage if necessary.
8. Configure security group:
Add a rule to allow inbound traffic on port 53 (UDP) for DNS.
Add a rule to allow inbound traffic on port 22 (TCP) for SSH.
9. Review and launch the instance.
- By using SSH or AWS Console
sudo apt-get update
sudo apt-get install -y docker.io
git clone https://github.com/yourusername/dns-server.git
cd dns-server
Build the Docker image:
sudo docker build -t dns-server .
Run the Docker container:
sudo docker run -p 53:53 dns-server
To configure your domain (e.g., ns2.aniketghavte.xyz) to point to your DNS server:
- Log in to your domain registrar's website.
- Navigate to the DNS management section.
- Add a new A record: Name: ns2 Type: A Value: Your EC2 instance's public IP address
- Save the changes.
This will ensure that ns2.aniketghavte.xyz points to your EC2 instance's port 53, where your DNS server is running.