Created
January 29, 2016 07:34
-
-
Save dineshsprabu/dd6bdab22e14e88953e7 to your computer and use it in GitHub Desktop.
DNS Lookup from NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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