Skip to content

Instantly share code, notes, and snippets.

@mogsdad
Last active September 12, 2018 05:48
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mogsdad/ece531531e0ef5dc355d to your computer and use it in GitHub Desktop.
Save mogsdad/ece531531e0ef5dc355d to your computer and use it in GitHub Desktop.
NSLookup - Google Sheets custom function to Perform a Network Service Lookup, using StatDNS API. From "Nslookup or dig in Google App Script" (http://stackoverflow.com/a/30610580/1677912).
/**
* Perform a Network Service Lookup, using StatDNS API.
*
* @param {"google.com"} dn A well-formed domain name to resolve.
* @return {String} Resolved IP address
* @customfunction
*/
function NSLookup(dn) {
// From gist.github.com/mogsdad/ece531531e0ef5dc355d
var url = "http://api.statdns.com/%FQDN%/a".replace("%FQDN%",dn);
var result = UrlFetchApp.fetch(url,{muteHttpExceptions:true});
var rc = result.getResponseCode();
var response = JSON.parse(result.getContentText());
if (rc !== 200) {
throw new Error( response.message );
}
var ip = response.answer[0].rdata;
return ip;
}
Copy link

ghost commented May 21, 2018

Getting an error for line 11

@neilerdwien
Copy link

According to:

https://www.statdns.com/api/

the StatDNS API service has been permanently shut down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment