I need to do recursive check DNS, like linux's mand
$ dig +recurse some.site
with nodejs. This 'request' have to return object of DNS, because I need to work with them.
I need this feature to take rightly DNS, it have to get round TTL(I'm not sure that it correctly sounds on English). Can standard dns module do this?
I need to do recursive check DNS, like linux's mand
$ dig +recurse some.site
with nodejs. This 'request' have to return object of DNS, because I need to work with them.
I need this feature to take rightly DNS, it have to get round TTL(I'm not sure that it correctly sounds on English). Can standard dns module do this?
Share Improve this question edited Sep 22, 2015 at 3:26 Horo asked Sep 21, 2015 at 12:56 HoroHoro 1021 silver badge10 bronze badges 1- 1 Please check if nodejs/api/dns.html helps. – Shubhangi Commented Sep 21, 2015 at 13:15
2 Answers
Reset to default 13You could use the core DNS module. The first example they give does a lookup of www.google.
var dns = require('dns');
dns.lookup('www.google.', function onLookup(err, addresses, family) {
console.log('addresses:', addresses);
});
Also have a look at this native-dns module
I have done it! I used this module.
First I define question:
var question = dns.Question({
name: 'somesite.',
type: 'A',
});
Second I do request to root server:
var dns = require('native-dns');
var standard_dns = require('dns'); //for dns.lookup() function
var req = dns.Request({
question: question,
server: { address: '199.7.91.13', port: 53, type: 'udp' },
timeout: 1000,
});
Then I do this:
req.on('message', function (err, answer) {
answer.authority.forEach(function(a){ //looking each authority server
var addresses = String(a.data),//stringify it
standard_dns.lookup(addresses, function(e, add){ //lookup this server with standard 'dns' module
var req = dns.Request({
question: question,//question for somesite.
server: {address: add}//do request on this server
})
req.on('message', function(e, a){
console.log(a);//a - is what you need
})
req.send(); //send request
})
})
});