Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active October 1, 2021 21:03
Show Gist options
  • Save JamoCA/83dc9aeaaa34ffd605cb to your computer and use it in GitHub Desktop.
Save JamoCA/83dc9aeaaa34ffd605cb to your computer and use it in GitHub Desktop.
Better ColdFusion DNS Look-ups using dnsjava.
<cfscript>
/* add dnsjava-*.jar to java path. Download from http://www.dnsjava.org/ */
thisDomain = "google.com";
dnsjava = createobject("java", "org.xbill.DNS.Address");
dnsResponse = dnsjava.getAllByName(thisDomain);
ips = [];
if (isArray(dnsResponse)){
for(i=1; i <= ArrayLen(dnsResponse); i++){
arrayappend(ips, dnsResponse[i].getHostAddress());
}
}
writeoutput(ThisDomain & " = " & arraylen(ips) & " IPs (" & arraytolist(ips, ", ") & ")");
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment