-
-
Save gotomypc/3963639 to your computer and use it in GitHub Desktop.
node.js IP reverse lookup
This file contains 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
var dns = require('dns'); | |
function reverseLookup(ip) { | |
dns.reverse(ip,function(err,domains){ | |
if(err!=null) callback(err); | |
domains.forEach(function(domain){ | |
dns.lookup(domain,function(err, address, family){ | |
console.log(domain,'[',address,']'); | |
console.log('reverse:',ip==address); | |
}); | |
}); | |
}); | |
} | |
reverseLookup('213.46.228.196'); |
This file contains 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
#!/bin/sh | |
node reverse-ip-lookup.js |
Single line 😎
import('dns').then(async (dns) => console.log(await dns.promises.reverse('8.8.8.8')))
😍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With promises: