I need to find the IP address of the server on which the page is currently running. I have a code that calls a third-party site and must pass a certain key, which changes depending on which server it is on. Is there a CGI variable or some way in ColdFusion to determine which IP address belongs to the host server?
I would use hostip.info APIYour IP address in XML: http://api.hostip.info/get_xml.phpYour IP address in HTML: http://api.hostip.info/get_html.php
, IP-, , , , , .
, , IP-, , IP-, ,
<cfset cName = CreateObject("java", "java.net.InetAddress").getLocalHost().getHostAddress()> <cfdump var="#cName#">
, , , , IP:
, , , , .
NAT - -, IP-, .
, , , .
- - - , IP- . CGI script, , , IP- ( , ).
CGI.LOCAL_ADDR IP- ( CFML PHP $_SERVER [ "SERVER_ADDR" ]). IIS Apache ColdFusion Railo, -, IP- IP-, ( , IP- , ).
The safest way would be to use a service like WhatIsMyIP . If the server is behind NAT, then the OS does not know the external IP address.
There are many questions in SO regarding this, see here .
<cfhttp url="http://www.whatismyip.com/" result="myresult" resolveurl="yes"> <cfoutput>#myresult.filecontent#</cfoutput>