host command not seeming to use /etc/hosts file

Chris Adams linux at cmadams.net
Thu May 1 21:12:38 UTC 2014


Once upon a time, Robert Moskowitz <rgm at htt-consult.com> said:
> Kind of thought so.  So is there an equiv command that follows
> system priorities for both dns and hosts file?

getent hosts www.google.com

That will follow the IPv6-before-IPv4 rules (so by default, if the host
has an IPv6 entry, only that will be shown).

To see all the matches, IPv6 and IPv4, you can use "ahosts" instead
(which also has "ahostsv4" and "ahostsv6" to get only a specific address
family).  That will return all socket types (so usually STREAM, DGRAM,
and RAW).  This is done via a calls to getaddrinfo() and so should match
the behavior of modern (akak IPv6-ready) programs.

-- 
Chris Adams <linux at cmadams.net>


More information about the users mailing list