dns-stub-resolver
v1.0.1
Published
This is a very basic DNS stub resolver - essentially a simple DNS client. It can only take a domain name and get the IPv4 address. This is how to use it:
Downloads
3
Readme
dns-stub-resolver
This is a very basic DNS stub resolver - essentially a simple DNS client. It can only take a domain name and get the IPv4 address. This is how to use it:
git clone [email protected]:BenLorantfy/dns-stub-resolver
cd dns-stub-resolver
npm install
./node_modules/.bin/ts-node ./src/main.ts [domain_name]
Here is some example output for a few domains:
Ben-Lorantfys-MacBook-Pro:dns_resolver ben$ ./node_modules/.bin/ts-node ./src/main.ts google.com
172.217.165.14
Ben-Lorantfys-MacBook-Pro:dns_resolver ben$ ./node_modules/.bin/ts-node ./src/main.ts benlorantfy.com
76.76.21.21
Ben-Lorantfys-MacBook-Pro:dns_resolver ben$ ./node_modules/.bin/ts-node ./src/main.ts twitter.com
104.244.42.129
You can also see the help page by running:
./node_modules/.bin/ts-node ./src/main.ts --help
This project was mostly to learn more about how DNS works. I learned a lot from this guide but I wrote the code without really looking at the rust version in this guide.
I may add support for more record types in the future, and possibly implement a recursive resolver so it doesn't have to depend on google's public DNS server.
What does this do?
This program does the following:
- Takes a domain name as input
- Constructs a DNS query packet. Basically a string of bytes representing a small DNS payload.
- Sends the DNS query packet over UDP to google's public DNS server
- Recieves the DNS response packet from google
- Parses the DNS response packet and finds the IP address
- Outputs the IP address to stdout