I have no problem getting the external ip and i use this:.. for those
interested a bit more added to make sure..
<?php

//Get the real client IP

function GetIP()
{
   if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"),
"unknown"))
           $ip = getenv("HTTP_CLIENT_IP");
       else if (getenv("HTTP_X_FORWARDED_FOR") &&
strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
           $ip = getenv("HTTP_X_FORWARDED_FOR");
       else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"),
"unknown"))
           $ip = getenv("REMOTE_ADDR");
       else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] &&
strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
           $ip = $_SERVER['REMOTE_ADDR'];
       else
           $ip = "unknown";
   return($ip);
}/*-------GetIP()-------*/

>?

----- Original Message -----

From: "Fredrik Bergström" <[EMAIL PROTECTED]>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Thursday, March 17, 2005 7:39 AM
Subject: Re[2]: [twsocket] router and IP


The only good way I have found to get your "external" IP address has
been to check a website for it.

Either make a small phpscript like this:
<?php
$ip = (getenv(REMOTE_ADDR))
    ?  getenv(REMOTE_ADDR)
    :  getenv(HTTP_X_FORWARDED_FOR);
echo $ip;
?>

or get it from parsing the xml on this page for example:
http://xml.showmyip.com/

/Fredrik

Thursday, March 17, 2005, 2:56:31 AM, you wrote:

> The website server can only see the cable-assigned IP (81.103.x.x).
> Your PC is assigned a local IP address (usually in the range
> 192.168.x.x).  This local IP address is not valid outside your local
> network.

> I'm not sure how you would programmatically find the router's IP address.



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be



-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to