I am in the shell and I want to know the corresponding IP address(es) for a hostname.
I know I could get it through Perl, PHP, Python or a number of other scripting languages (probably even awk!), and this will be my workaround, but I am surprised that there seems to be no command-line tool to do this, no simple wrapper around getaddrinfo()
.
Am I wrong? Is there one? host
, dig
and getent
do not count, I want something that uses the libc and acts according to /etc/nsswitch.conf
, and something that is probably installed on any (linux) system by default.
Moved here from https://stackoverflow.com/questions/20211326/is-there-a-standard-command-line-tool-to-do-a-hostname-lookup
Answer: I was wrong, getent
does not exclusively look in /etc/hosts
, it actually does a proper lookup.