> You could cfexecute ipconfig or ifconfig, and then parse the results.

Or you could use nslookup/dig. I used this a while back to get the true IP
vs the local private address. If it's a local address you want, the
java.net.InetAddress that Martin posted is what you need (cfdump that for
some more goodies).


<cfset domainname = "google.com">

<cfexecute name="C:\windows\system32\nslookup.exe" 
           arguments="#domainname#" 
           timeout="5" 
           variable="results" />

<cfoutput>#listfirst(trim(listlast(results, ":")))#</cfoutput>


Here's what a basic google nslookup from my windows machine

Server:  gnbonc-dns-cac-03.triad.rr.com
Address:  24.28.227.63

Non-authoritative answer:
Name:    google.com
Addresses:  216.239.57.99, 216.239.37.99


If I check my site (and most others I deal with) it's more along the lines
of...

Server:  gnbonc-dns-cac-03.tri
Address:  24.28.227.63

Non-authoritative answer:
Name:    acoderslife.com
Address:  216.27.16.80


Notice the word Address: with one ip instead of 
Addresses: and a list of IPs

Anyway, trim listlast with a colon delim shoud get you everything after that
last 'Address(es):' which is USUALLY what you want but just incase it's a
list of addresses, listfirst or last on that too.

Of course, if it is a linux server it'll be a bit more challenging with the
dig results but do-able, just look for the "ANSWER SECTION:"

 
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com


-----Original Message-----
From: Thomas Chiverton [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 06, 2005 8:38 AM
To: CF-Talk
Subject: Re: #CGI.SERVER_NAME# to display IP

On Thursday 06 October 2005 12:22, Michael T. Tangorre wrote:
> the IP appears in the URL instead of the server name or using a Java class
> to translate.

You could cfexecute ipconfig or ifconfig, and then parse the results.
You wouldn't be able to tell which of several interfaces was being used 
though, even if you use a Java class afaik.

-- 

Tom Chiverton 
Advanced ColdFusion Programmer



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:220482
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to