Recently, I stumbled upon an intriguing video on youtube that delved into the fascinating world of DNS servers and their potential applications. As a person with a keen interest in networking and artificial intelligence, I found this project particularly enlightening. It opened my eyes to how we can leverage DNS servers to provide fast responses to complex queries, and I couldn't wait to share my insights and experiences from this project.
Understanding DNS Servers
Before diving into the project, let’s clarify what a DNS (Domain Name System) server is. Think of it as the internet's phone book. When you type a website's name into your browser, the DNS server translates that human-readable domain name into an IP address that computers can understand. This process is crucial for navigating the web efficiently.
What's the Difference: TCP vs. UDP
TCP (Transmission Control Protocol) is a connection-oriented protocol that ensures reliable communication between devices. It establishes a connection before data is sent and guarantees that packets arrive in order and without errors. However, this reliability comes at the cost of speed.
UDP (User Datagram Protocol), on the other hand, is a connectionless protocol that allows for faster data transmission. It doesn’t guarantee delivery or order, making it ideal for applications where speed is more critical than reliability, such as video streaming or online gaming. Since DNS queries are typically short and require quick responses, UDP is the preferred choice for DNS servers.
So What's the matter?
Example: Converting Bytes to Megabytes

One of the fascinating examples presented in the video was the conversion of data sizes, such as bytes to megabytes (MB) and vice versa. This is a common task in networking and data management.
1 byte is equal to 0.000001 megabytes (MB).
Conversely, 1 megabyte (MB) is equal to 1,000,000 bytes.
This conversion is crucial when dealing with data transfer rates and storage capacities, especially in a world where data is king.
So can we directly ask this types of queries to DNS server? 🤔 The answer is No, As the primary goal of DNS server is to resolve IP address and domain name records like (A, AAAA, CNAME, MX, TXT, NS, SOA etc.)
What's my Goal? Using UDP protocol as DNS server which can resolve these queries
Input: user queries
Output: TXT record as a response
Benefit: Making internal communication more fast and efficient
Setting Up the Project
1. Create a node project install node modules and make index.js
2. Define a function to create server pass query as parameter
3. Setup gemini api key and setup in project
4. Parse and join the query inputs ('.') to (' ') in api.
5. Create api promt (Answer the questions in one line or in one word)
6. Start server and go to command promt
7. Run - dig TXT @localhost -p 8000 +short <query>
Example query:
dig TXT @localhost -p 8000 +short What.is.2.+.2
Response: "4\010"
Follow Up
1. Host this project on EC2 on port 53.
2. Add more features or create functions like - dig mumbai.time @dns.toys
3. Add a domain name - your domain - dns.your_domain
Conclusion
This project has been a remarkable learning experience, blending networking concepts with artificial intelligence. By transforming a DNS server into an AI
Connect with Me
I’d love to hear your thoughts, feedback, or just have a chat about blogging! Feel free to connect with me on LinkedIn or check out my other projects here.
