On 04/23/2014 01:31 PM, Chris Adams wrote:
Once upon a time, Robert Moskowitz <rgm(a)htt-consult.com> said:
> I have noticed that the Host command is always returning first IPv4
> addresses, and then IPv6 addresses. So I asked on the BIND list can
> got the following:
You asked the BIND list a different question than you are asking here.
BIND returns the record type requested, in random order when there is
more than one (e.g. multiple A records). To get multiple types, you
have to send multiple queries (ANY is special). The "host" command-line
tool does not duplicate the way an application does lookups. "host"
(per the man page) specifically by default looks up A, AAAA, and MX, in
Applications on the other hand use a few different library calls to
convert names to addresses, most commonly gethostbyname() (old,
IPv4-only) or getaddrinfo() (new, can handle multiple address families).
For modern applications that use getaddrinfo(), the default is to follow
the ordering rules defined in RFC 3484 that (in general) put IPv6
addresses ahead of IPv4 addresses.
Is there a command line that will 'just use' getaddrinfo taking a fqdn
as input and return the results? My attempt to find such has come up
empty; my search foo is typically weak...
You can control some of the ordering with /etc/gai.conf; see
gai.conf" for more info.
There is a sample one, to show you what the defaults are. I bit of a
learning experience here.