This is a basic custom DNS server implemented in Node.js with no external dependencies. It allows you to run a DNS server that can resolve domain names to IP addresses. You can use this DNS server for local testing or as a base for more advanced DNS server functionality.
-
Clone this repository to your local machine:
git clone https://github.com/Ilikepizza2/dns-server-node.git
-
Navigate to the project directory:
cd dns-server-node
-
Install the necessary dependencies (there are none for this project):
# There are no external dependencies
-
Start the custom DNS server:
sudo node ./index.js
This will start the DNS server on the default port 53. Note: sudo is required because ports<80 are only accessible through root previliges
-
Test the DNS server using the
dig
command. For example, to resolve the IP address of "example.com," run:dig example.com @127.0.0.1
Replace
127.0.0.1
with the IP address of your DNS server if it's running on a different machine. -
The DNS server should respond with the IP address associated with the domain name you queried.
-
You can verify the response by running
dig example.com
This will respond with the actual address from the server your machine points to.
You can customize the DNS server behavior by editing the index.js
file. For example, you can add your own DNS records or modify the server's behavior as needed for your project.
You can add the .zone
file into the /zones/ directory. You can also parse any txt file by installing dns-zonefile
and running the script addZone.sh
which is included. This wasn't supported by default because I didn't want to include any external dependency.
npm i dns-zonefile
chmod +x ./addZone.sh
./addZone.sh