ahosts calls getaddrinfo. This function enumerates all protocols for a given name, so it can return both IPv4 and IPv6 addresses in the same call. What it returns is determined by the settings in /etc/gai.conf. Because many applications are still struggling to cope with IPv6, most distributions prefer IPv4 by default and only use IPv6 by explicit request.