kanish has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

How to get Client IP Address in CGI

I tried %ENV Variable. But it not showing Client IP Address.

Please Advice me.

Thanks
Kanishk

Replies are listed 'Best First'.
Re: Get Client IP Address
by ikegami (Patriarch) on Feb 16, 2006 at 06:54 UTC

    $ENV{REMOTE_ADDR} (IP address) and $ENV{REMOTE_HOST} (domain name or undefined), as documented in the CGI spec.

    remote_host is CGI's interface to this data.

      Thanks for your answer.. its working..

      But It failed when client using through proxy.

      Please advice me.

        Failed? You mean you got the proxy's address? Well, that's to be expected since the proxy IS the client of the server. There's no way of knowing more than that from HTTP. You might be able to do more using JavaScript since that will run in the browser, not on the server.