Page 1 of 1

Get IP Address

Posted: Tue May 24, 2005 5:20 am
by thomas777neo
Hi All

I am trying to get the ip address for my machine (I am the server). I have tried this:

Code: Select all

$ip = $REMOTE_ADDR;
Which returns 127.0.0.1, I am trying to get my machines ip of 192.x.x.x. How would I go about doing this?

Posted: Tue May 24, 2005 5:25 am
by AlexB
I've always used this.

Code: Select all

$ip = $_SERVERї&quote;REMOTE_ADDR&quote;];

Posted: Tue May 24, 2005 5:30 am
by thomas777neo
That does the same thing, it outputs 127.0.0.1.

I need the "real" ip address of my machine, not the php configuration.

Posted: Tue May 24, 2005 7:18 am
by cheatboy00
well if your on a windows machine you can get your local lan ip by going into the command prompt and entering in "ipconfig" without the quotes... and it'll give you your address

though if your looking for a php function or something that will get someone elses lan ip I'm not sure you can do that.

Posted: Tue May 24, 2005 9:43 am
by Wayne
not quite sure if this is what you are trying to get at, but ....

if you mean you are running the server and browser on the same machine, and you want to get the real IP address of the browser, when you enter the url dont use 127.0.0.1 or localhost use your actual 192.x.x.x IP address. That should return the address you are looking for.

Posted: Wed May 25, 2005 4:16 pm
by thomas777neo
That's almost embarrassing :oops: . Thanks for that !!!