Get the server's ip address

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm looking for a script, which finds the ip address of the server, it's  
running on
It should be compatible with both Linux and Windows

Re: Get the server's ip address

$_SERVER['SERVER_ADDR'] // should work for php/apache

you could try seeing if there's anything specific to your webserver by

Are you running a CLI script?

There might be something in pear, I'd check the Net or Socket related
you could also see if there's something in pear...

If the socket_* methods aren't blocked, you could attempt to make an
outgoing socket connection to an HTTP port or something you _know_ you
can connect to (i.e. ' '), and then read the local
IP address of outgoing socket. for example:

$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($sock, '', 80);

hope it helps


On Oct 14, 1:20 pm, at(nospam) <"lasse(at(nospam))"> wrote:
Quoted text here. Click to load it

Site Timeline