Home > OS >  Make a dns resolver with node js
Make a dns resolver with node js

Time:01-17

is there any way i can make a DNS resolver with Node JS that will resolve every domain name as for example 0.0.0.0? I have looked at the official Node JS DNS module docs but it is confusing and i cant find a straight answer. Thanks!

CodePudding user response:

there are exemples everywhere :)

if you want to resolve a domain to an ip adress :

let dns = require('dns');
dns.resolve("google.com", function(err, data) {
    console.log(data)
});
// > e.g. Array [ '216.58.213.78' ]

CodePudding user response:

Yes, you can do this. If you want to look up domain names and get names the Node DNS API is the tool. You don't say what you found confusing, but if you google around there are plenty of examples out there.

If you want to start from scratch to build your own DNS server, use the TCP network API and UDP socket API. You'll also want to read the DNS RFC. If you found Nodes DNS API confusing, then this route (no pun intended) is probably not for you.

If you just want to host dns w/ node and manipulate traffic, then you can use a library such as bindns.

  •  Tags:  
  • Related