http://qs321.pair.com?node_id=23449

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

How can I get a remote user's IP using Perl?

Originally posted as a Categorized Question.

  • Comment on How can I get a remote user's IP using Perl?

Replies are listed 'Best First'.
Re: How can I get user's IP using Perl?
by cwest (Friar) on Jul 20, 2000 at 22:24 UTC
    $ENV{REMOTE_ADDR}
    For that matter, you could use remote_host() from CGI.pm.

    Also, try this:

    #!/usr/bin/perl -w use strict; $|++; use CGI; my $cgi = CGI->new; print $cgi->header, $cgi->start_html, $cgi->pre( ( map { "$_\t$ENV{$_}\n" } keys %ENV ) ), $cgi->end_html;
    That was untested, but I'm pretty sure it's right :-)
Re: How can I get a remote user's IP using Perl?
by infoninja (Friar) on Jul 20, 2000 at 22:17 UTC
    The remote user's IP address is in $ENV{'REMOTE_ADDR'}, although it's pretty forge-able.
      How is it forge-able on NT?
Re: How can I get a remote user's IP using Perl?
by sinan (Sexton) on Aug 27, 2000 at 12:36 UTC