Ugh..  Forgot to CC in the list...

-----Original Message-----
 
I use this little subroutine :

use Socket;

sub nslookup {
   my $ipaddress = shift;

   my $dnsname =
gethostbyaddr(pack('C4',split(/\./,$ipaddress)),AF_INET);
   if ((! defined $dnsname) || ($dnsname eq '')) {
      print "*** $ipaddress has no nodename ***\n";
      $dnsname = $ipaddress;
   }

   return($dnsname);
}

Works fine on everything...  If you're unable to resolve remote names,
I'm guessing you have other issues...  This information should be
returned by the name server that's set up on the host computer.  In
fact, it may even resolve names when not connected to the network
because of caching..  (this depends on the os and setup) ...  The fact
that the ip's you're trying to resolve are elsewhere on your WAN is
irrelevant.  The DNS Server is the point of contact for the name/reverse
resolution.

---------------------------
Jason H. Frisvold
Senior ATM Engineer
Engineering Dept.
Penteledata
CCNA Certified - CSCO10151622
[EMAIL PROTECTED]
---------------------------
"Imagination is more important than knowledge. Knowledge is limited.
Imagination encircles the world." -- Albert Einstein [1879-1955]


-----Original Message-----
From: John Edwards [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, April 30, 2002 9:33 AM
To: Perl Beginners ([EMAIL PROTECTED])
Subject: Name resolution from IP

How can I resolve a machine name from an IP address? The machine that
the
script is running on is NT4.

I've tried this (with use Socket qw(:DEFAULT :crlf); at the top of the
script)

$machine_name = gethostbyaddr(inet_aton($userIP), AF_INET) or die "Can't
resolve $userIP: $!\n"

It works on the LAN, but not across a router to the remainder of our
WAN.
Any ideas?

-- 
John Edwards
IT Support
Runecraft Leeds

0113  2206317
07961 356186
www.runecraft.co.uk

--
Disclaimer: These are my opinions and probably not those of my employer,
since I developed them long before I came to work for my current
employer.





--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed
or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may
be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to