How to get the IP address of your application server

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?

+5
source share
6 answers

I would use hostip.info API
Your IP address in XML: http://api.hostip.info/get_xml.php
Your IP address in HTML: http://api.hostip.info/get_html.php

+2
source

, IP-, , , , , .

, , IP-, , IP-, ,

 <cfset cName = CreateObject("java", "java.net.InetAddress").getLocalHost().getHostAddress()>

 <cfdump var="#cName#">
+5

, , , , IP:

  • , , , , .

  • NAT - -, IP-, .

, , , .

- - - , IP- . CGI script, , , IP- ( , ).

+4

CGI.LOCAL_ADDR IP- ( CFML PHP $_SERVER [ "SERVER_ADDR" ]). IIS Apache ColdFusion Railo, -, IP- IP-, ( , IP- , ).

+2
source

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 .

+1
source
<cfhttp url="http://www.whatismyip.com/" result="myresult" resolveurl="yes">
<cfoutput>#myresult.filecontent#</cfoutput>
0
source

All Articles