The script will be processing 500+ lines of IP addresses; not something I want to spawn out to do an
NSLOOKUP or HOST command for each one, really....
The /etc/nsswitch.conf file here specifies only "hosts: files dns", and the IP addresses in question do not appear in the /etc/hosts file, so it should be getting the information from DNS just like NSLOOKUP and, presumably, HOST would get it from anyway, right? (HOST doesn't appear to be available, either. The OS is Solaris 9, eventually Solaris 10).
In fact I've already discussed this much so far with colleages. We're baffled as to why, in this situation, we consistantly get different results for a big chunk (maybe 15%) of the IP addresses in the file using gethostbyaddr() as with NSLOOKUP.
Main Topics
Browse All Topics





by: nociPosted on 2007-06-19 at 13:38:12ID: 19319642
gethost by address is driven using the (nsswitch.conf file on most systems or equivalnet)
and also takes into account a /etc/hosts file or even different sources (ldap, nis, yp etc.).
nslookup uses dns first.
You get the perl script to use the nslookup itself and cature the output and parse that....
or use the 'host' command if available (part of the bind tools)
output should be something along:
host xyz
xyz.my.domain has address 192.168.x.y
host 192.168.x.y
y.x.168.192.in-addr.arpa domain name pointer xyz.my.domain.
In perl you can this data by:
$var = `host xyz`;
and equivalent funtions.