Thu 19 Feb 2009
Coldfusion: DNS Reverse Lookup
Posted by JC under ColdFusion
[3] Comments
I have no idea why this information was so difficult to find, but I'm posting it here in case I ever need it again.
To do a reverse lookup in coldfusion:
<cfscript>
rawIP = createObject("java", "java.net.InetAddress").getByName('#ipaddress#').getAddress();
hostname = createObject("java", "java.net.InetAddress").getByAddress('#rawIP#').getHostName();
chostname = createObject("java", "java.net.InetAddress").getByAddress('#rawIP#').getCanonicalHostName();
</cfscript>
Note — this is slow. If you're doing them in bulk, you may need to go in small batches or set a higher timeout.
Also, this was perhaps useful: http://api.hostip.info/get_html.php?ip=#ipaddress#&position=true — returns the country, city, state, and geotag info for an IP address, where available.