DNS – Host Lookup That Respects /etc/hosts

dnshosts

Utilities like host and dig let you see the IP address corresponding to the host name.

There is also the getent utility that can be used to query /etc/hosts or other NSS databases.

I am looking for a convenient standard utility (which is available in Debian, say) which resolves a host name regardless of where it is defined.

It should be more or less equivalent to

ping "$HOST" | head -1 | perl -lne '/\((.*?)\)/ && print $1'

Best Answer

The only command that I am aware that does what you want is resolveip:

http://linux.die.net/man/1/resolveip

However it only comes with mysql-server, which may not be ideal to install everywhere.

Related Question