Subject: Re: Lookup for a non-fully qualified domain fails to fall back to IPv4

Re: Lookup for a non-fully qualified domain fails to fall back to IPv4

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 8 Aug 2010 19:59:27 +0200 (CEST)

On Thu, 5 Aug 2010, Martin Lemke wrote:

> I was working with curl with c-ares, when discovered a problem that
> non-fully qualified domain names fail to be resolved. For some reason c-ares
> fails to fall back to IPv4 when the IPv6 lookup doesn't bring any result.

The general problem here is that c-ares has no getaddrinfo() implementation
and that is the primary function used for name resolving in modern
applications. It is also used to provide _both_ IPv6 and IPv4 resolved names
and the obvious way clients like (lib)curl would rather do name resolves.

In the absense of this "correct" function, we have a number of more or less
crude kludges in c-ares that can make it do IPv6 first and then fallback to
IPv4 if the first fails according to some specific rules (as mentioned).

This is a flawed idea and concept. For example, if a site has both IPv6 and
IPv4 addresses (which more and more are likely to have over time), c-ares will
then happily return only the IPv6 ones to the client but there are in fact
several situations where the client will only succeed to connect to the IPv4
addresses. But c-ares won't return both types in one response.

In curl's case for example, there are times when you have to force it to IPv4
to be able to connect because of this.

So, while there may be ways to extend and improve this current approach, it
will NEVER be a really good way and it can't replace a proper libc's
implementation of getaddrinfo(). We simply have to make an implementation of
that to be able to provide a better API and experience.

-- 
  / daniel.haxx.se
Received on 2010-08-08