Skip to main content

Command Palette

Search for a command to run...

My Own Dns Server

Updated
•2 min read
My Own Dns Server
B

Full-Stack Developer | MERN + Next.js | DevOps & Cloud Enthusiast

I specialize in building dynamic web applications using the MERN stack and Next.js. Currently exploring DevOps and cloud technologies to streamline workflows, automate deployments, and optimize cloud infrastructure for scalable, efficient solutions.

How to use ?

For calculation:-

dig @dns.deploylite.tech MX calculate.2+2
#feel free to change 2+2 to something else 
dig @dns.deploylite.tech MX calculate.2+2 +short

For generating random number:-

dig @dns.deploylite.tech MX generate-random.rand
#using +short
dig @dns.deploylite.tech MX generate-random.rand +short

For getting any timezone:-

dig @dns.deploylite.tech MX timezone.ASIA/KOLKATA
#using +short
dig @dns.deploylite.tech MX timezone.ASIA/KOLKATA +short
dig @dns.deploylite.tech MX timezone.US/Pacific +short
dig @dns.deploylite.tech MX timezone.Singapore +short
#you can use any time zone for the query?
#for supported timezone visist:-https://timeapi.io/api/timezone/availabletimezones

For ai response . Ask anything to ai:-

dig @dns.deploylite.tech MX ai.what.is.dns +short
#Modify this query . And if you have space on your prompt add .
dig @dns.deploylite.tech MX ai.what.is.js +short

For Piyush Sir's Playlist recommendation: Ask your query about the resources you need for a tutorial, and you'll get a full-fledged playlist curated by Piyush Sir:-

dig @dns.deploylite.tech MX tutorial.nextjs +short
dig @dns.deploylite.tech MX tutorial.advanced.js +short
#feel free to ask what do you want.
dig @dns.deploylite.tech MX tutorial.appwrite +short
#gives and not found message if it's not there

For Piyush Sir's Course recommendation: Ask your query:-

dig @dns.deploylite.tech MX course.docker +short
dig @dns.deploylite.tech MX course.nextjs +short
#feel free to ask of your choice
dig @dns.deploylite.tech MX course.web.dev.cohort +short

Currently, these features are available, with more exciting features coming soon.

Here is a step by step guide how to deploy your own dns server .

How to Deploy ?

  1. Start an ec2 instance and below run the commands to cotinue

allow 53 port in security group - > custom udp → 53 → allow access from anywhere

sudo apt update && upgrade -y

Install nodejs

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm install v21.7.0

Clone Your repo

git clone repo_url
cd repo_folder
npm i

Basic Configuration for opening port 53. I see that systemd-resolved is using port 53. Let's disable it and free up the port:

  1. First, stop and disable systemd-resolved:
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved

You might need to update your DNS resolver settings. Edit /etc/resolv.conf:

sudo nano /etc/resolv.conf

Replace its contents with:

nameserver 8.8.8.8  # Google DNS
nameserver 8.8.4.4  # Google DNS backup

To prevent systemd-resolved from starting again on reboot:

sudo systemctl mask systemd-resolved

If you get permission errors, make sure you've set the capabilities correctly:

sudo setcap cap_net_bind_service=+ep $(which node)

Start the dns server on background. Install Pm2.

npm i -g pm2
pm2 start "node index.js" --name dns
pm2 save

Congratulations Your Server is up and running.


🖥️ Devops

Part 3 of 5

Explore the world of DevOps in this comprehensive series! Learn about automation, CI/CD, infrastructure as code, and best practices. Dive into tools like Docker, Kubernetes, Jenkins, and more to streamline development and operations efficiently.

Up next

Dockerfile Generation Made Easy: Build, Download, and Commit with DockerGen

Creating a Dockerfile from scratch can be time-consuming and complicated, especially if you're aiming to follow Docker best practices. But don’t worry—we’ve built a Dockerfile Generation Website that simplifies the entire process. With our tool, you ...

More from this blog

"

"Mastering DevOps, Full Stack Development, AWS & Cutting-Edge Tech | Insights & Tutorials

13 posts

sudo certbot -d '*.host.deploylite.tech' --manual --preferred-challenges dns certonly