Skip to content

Instantly share code, notes, and snippets.

@dineshsprabu
Created January 29, 2016 07:34
Show Gist options
  • Save dineshsprabu/dd6bdab22e14e88953e7 to your computer and use it in GitHub Desktop.
Save dineshsprabu/dd6bdab22e14e88953e7 to your computer and use it in GitHub Desktop.
DNS Lookup from NodeJS
/* npm install dns */
var dns = require('dns');
/* domain name to lookup */
domain_name = 'example.com';
dns.lookup(domain_name, function(err, addresses, family){
/* handle if look up fails inside if condition */
if(err){return console.log(err.stack);}
/* handle a successful lookup */
console.log(addresses);
console.log(family);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment