Get the server's ip address

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • at(nospam)

    Get the server's ip address

    Hey

    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
  • ruibalp@gmail.com

    #2
    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
    print_r($global s)

    Are you running a CLI script?

    There might be something in pear, I'd check the Net or Socket related
    packages
    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. 'http://google.com:80') , and then read the local
    IP address of outgoing socket. for example:

    $sock = socket_create(A F_INET, SOCK_STREAM, SOL_TCP);
    socket_connect( $sock, '66.102.7.147', 80);
    socket_getsockn ame($sock,$hn);
    print($hn);
    socket_close($s ock);

    hope it helps

    tg

    On Oct 14, 1:20 pm, at(nospam) <"lasse(at(nosp am))the87boy.dk "wrote:
    Hey
    >
    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

    Comment

    Working...