Pete Freitag Pete Freitag

Reverse IP Address Lookup with ColdFusion + Java

coldfusionjava

I needed to do a reverse lookup on some IP addresses in a database today. I found that you can do this pretty easily with java, and just as easily with ColdFusion. Here it is:

<cfset inet_address = CreateObject("java", "java.net.InetAddress")>
<cfset host_name = inet_address.getByName("66.249.66.99").getHostName()>
<cfoutput>#host_name#</cfoutput>

In java this would simply be:

System.out.println( java.net.InetAddress.getByName("66.249.66.99").getHostName() );

Like this? Follow me ↯

Reverse IP Address Lookup with ColdFusion + Java was first published on January 10, 2007.

If you like reading about dns, ip, lookup, cfml, java, or inetaddress then you might also like:

FuseGuard Web App Firewall for ColdFusion

The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.

Comments

Or you could use: <cfscript> writeOutput(CreateObject("java", "java.net.InetAddress").getByName("66.249.66.99").getHostName()); </cfscript> [ ]'s great post =)
by Fernando S. Trevisan on 01/10/2007 at 2:29:22 PM UTC
OR: <cfoutput>#CreateObject("java", "java.net.InetAddress").getByName("66.249.66.99").getHostName()#</cfoutput> As well =))
by Fernando S. Trevisan on 01/10/2007 at 2:52:25 PM UTC
Right on Fernando - I wasn't trying to make it look easier in java, but after reading the post again some might have come away with that. The same shortcuts I used in the java example could be used in ColdFusion as you did, above.
by Pete Freitag on 01/10/2007 at 3:55:05 PM UTC
Wow. I had a need for using the InetAddress Java class today as well. I planned on blogging it, but you beat me to it.
by Scott F Stroz on 01/10/2007 at 4:56:26 PM UTC
We also use inet_address.getLocalHost().getCanonicalHostName() for one of our sites in a cluster so if a client has an issue we can have them view source and read out the machine name.
by Adam Howitt on 01/11/2007 at 6:49:03 AM UTC
http://www.ipgp.net is a good tool to view information about ip addresses
by Lucian on 02/10/2007 at 3:20:42 PM UTC
why not use this accurate ip address locator: http://www.ip-adress.com
by fira on 02/27/2007 at 3:02:18 PM UTC