: $hostadd = $ENV{REMOTE_HOST};
:
: print "Host : $hostadd\n";
:
: But it isnt working , all I see is
:
: Host:
Your server (I'm assuming Apache) may be configured with:
HostnameLookups Off
If this is the case, then the server will not try to resolve IP
addresses into hostnames. This is usually done as a speed
optimization. Even with this option turned on, thoug, some IP addresses
simply won't resolve into a name.
You will always get $ENV{REMOTE_ADDR}, which is the IP address. You
can use gethostbyaddr() to try to resolve this into a name. Here's
an example of usage:
my $addr = pack('C4', split(/\./, $ipAddress));
my $AF_INET = 2;
my ($name, $aliases, $addrtype, $length, @addrs)
= gethostbyaddr($addr, $AF_INET);
$name will contain the hostname (if you can get it); $aliases contains
(I think) a space-separated list of alternate names for that IP
address. For the rest, do "perldoc -f gethostbyaddr".
-- tdk