As i understand, host/nslookup/dig only query DNS server to resolve name to ip.
ping can query both, but it seems if ping is blocked, ping won't return IP.
traceroute can query both, but i am not able to test if traceroute is blocked, What is the result?
Neither ping/traceroute is decent tool to do the job,any other ideas?
pludi
2
Neither ping nor traceroute query the host you're trying to reach, they too use DNS to resolve the name to an IP.
Try this:
#! /usr/bin/perl
printf "%s\n", @ARGV[0];
($name, $aliases, $addrtype, $length, @addrs) = gethostbyname(@ARGV[0]);
foreach $addr (@addrs) {
($b1,$b2,$b3,$b4) = unpack('C4',$addr);
printf "%d.%d.%d.%d \n", $b1,$b2,$b3,$b4;
}
exit 0;
getent hosts [hostname]
This will query whatever name resolution you have configured in /etc/nsswitch.conf. ie:
getent hosts mybox