http://www.perlmonks.org?node_id=526667

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

I know that $ENV{REMOTE_ADDR} returns the IP address of a visitor. How do I get the hostname of a visitor?

For example, this website tells you your hostname:
whatismyipaddress.com/staticpages/index.php/whatismyhostname

Replies are listed 'Best First'.
Re: how do I get a website visitor's host address
by McDarren (Abbot) on Jan 31, 2006 at 06:05 UTC
      ah, ok it can be (and probably is a Perl question :)

      You might look here: CGI Environment Variables as well.

      "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
Re: how do I get a website visitor's host address
by idle (Friar) on Jan 31, 2006 at 06:06 UTC
    $ENV{'REMOTE_HOST'}
Re: how do I get a website visitor's host address
by l.frankline (Hermit) on Jan 31, 2006 at 06:12 UTC

    Hi,

    $ENV{HTTP_HOST} = whatismyipaddress.com
    $ENV{PATH_INFO} = staticpages/index.php

    cheers

    Don't put off till tomorrow, what you can do today.

Re: how do I get a website visitor's host address
by strat (Canon) on Jan 31, 2006 at 09:34 UTC

    But don't put too much trust into this ip or hostname, because often it's a proxy's hostname or ip-address and not the enduser's one

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Re: how do I get a website visitor's host address
by jbrugger (Parson) on Jan 31, 2006 at 06:04 UTC
    this isn't Perl related, is it?
    But anyway, try digging into the host name lookup :)
    dig xxx.xxx.xxx.xxx host xxx.xxx.xxx.xxx nslookup xxx.xxx.xxx.xxx
    and there are more possible ways.

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.