From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8511 Path: news.gmane.org!not-for-mail From: Jameel Al-Aziz Newsgroups: gmane.linux.lib.musl.general Subject: Re: resolv.conf ordering Date: Tue, 15 Sep 2015 12:56:41 +0000 Message-ID: References: <20150915044321.GM17773@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1134e2ec31370f051fc8b7b5 X-Trace: ger.gmane.org 1442321840 31579 80.91.229.3 (15 Sep 2015 12:57:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Sep 2015 12:57:20 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8523-gllmg-musl=m.gmane.org@lists.openwall.com Tue Sep 15 14:57:08 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZbpnH-0004Zp-L5 for gllmg-musl@m.gmane.org; Tue, 15 Sep 2015 14:57:07 +0200 Original-Received: (qmail 21936 invoked by uid 550); 15 Sep 2015 12:57:04 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 21884 invoked from network); 15 Sep 2015 12:57:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jalaziz.net; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=LXuQKuPnBMP18IKmxA1bTk66BY2dUIAqcujNuFFdTeI=; b=d1epCKb5tgkkXT/0Y6Vbam6LazQWi+vHz75LQsJv0I9Ohk1QoiN/NQVj34HFy5GFTU UFEMYOyII9zvtTKp2kjkViue+3ktGgkohjwQ27HqPzhBJIFN+A6hGCdHjcnVX+lEW4MB FfKfUxubObkyP9XtotmH5WElUFsXjPGNatROo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type; bh=LXuQKuPnBMP18IKmxA1bTk66BY2dUIAqcujNuFFdTeI=; b=IzvUzL6Rr/cI3O+20z4Dgr9Mns0aEG1UBfyAI3KceEY2flI8YcqxnIZhknUbnM0C5G Q0SZGW/j0ZzZFL4tcpyWMYXsIRpu7GFY/2/+x23en0zv09gNoZvgL87pAYp7ZbfXaEI8 MHFR52HZb76c9KAWmJ5w6ZHGn07/gWcDYBqHV96vx1gagAquaQDOgTwXHIuaVwy0zFXl g5RZ2JD6Z0D7dsc9MOBBLOjToB7saor6mljwJ8UUg0d5Uyguc5uj8i7AOwl/nRRKGPw8 EhfnFdPXwpLf3xzqdfWM7XvQpl616grsHxovKJXIRY7olvpa+hz1+Kf7ur5hcA1VhQhT W18A== X-Gm-Message-State: ALoCoQldjQZKpqrA9UBLtkKouDlI/Rgl/7RccRyCrsat0sIcgVldzbGNugJX2MBux3reLzlWL0zV X-Received: by 10.202.201.80 with SMTP id z77mr16535603oif.112.1442321810922; Tue, 15 Sep 2015 05:56:50 -0700 (PDT) In-Reply-To: <20150915044321.GM17773@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:8511 Archived-At: --001a1134e2ec31370f051fc8b7b5 Content-Type: text/plain; charset=UTF-8 Thanks for the response! I would love to know more about the conversation on IRC. I almost feel like there are valid arguments on both sides. In a distributed environment, where machines and services come and go, it's pretty difficult to guarantee consistent records both reliably and quickly. While I was able to semi-solve my problem by enabling recursors through Consul DNS, I realized that I have a chicken and egg problem. The caveat here is this is particular to docker and some of the decisions they've made. The basic issue is that I have some containers that need to be run with "--net=host" and some that do not. In the "--net=host" containers effectively copy over the host's resolv.conf. In order to make sure everything can be resolved, I need to guarantee that Consul is setup as early as possible. However, in the case that the setup process needs DNS, you run into a problem. I could do some clever hackery to use the default host DNS and overwrite the host's /etc/resolv.conf after setting up Consul DNS, but that's not the greatest solution. This problem can also occur with bridged-networking containers if you choose to specify the "dynamic" DNS server as a default dns option to the docker daemon. Put in more simple terms, we need normal DNS resolution while bootstrapping, then as services register themselves, we need dependent services to be able to look up the newly registered entries. Effectively, the consistency is delayed at best. The other issue here is that having recursion enabled just feels wrong and insecure. Sure, this is all behind a VPC, but I like to err on the side of caution. I am probably wrong here, but it seems that the musl logic is only valid when all nameservers are consistent. However, with dynamic service registration, that consistency comes at the cost of speed. The behavior we would ideally want is as you mentioned: "Assuming no _conflicting_ positive responses, it would need to do something like forward positive responses as soon as it has at least one positive response from upstream, but only forward negative responses once it has a negative response from _all_ upstream sources." I'm almost certain we can accomplish what we want by having dnsmasq or some other dns proxy/cache try Consul DNS first and then fallback upstream for non-authoritative domains. The proxy has to be available very early on, which is entirely doable in our scenario. However, it does add another layer of indirection, which is just another potential failure point. All that being said, I definitely understand why the decision was made, just would be nice to have an option to enable the "robust" logic! :) On Mon, Sep 14, 2015 at 9:43 PM Rich Felker wrote: > On Tue, Sep 15, 2015 at 03:25:20AM +0000, Jameel Al-Aziz wrote: > > I'm sure this has been brought up before, but just thought I'd reach out > > see if there's a solution. > > > > I use musl on Alpine via Docker. I encountered issues today where DNS > > wasn't resolving the way we expect in our images. I finally managed to > > trace it down to musl's resolver ( > > > http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc#Name_Resolver_.2F_DNS > > ). > > > > We configure resolv.conf with three DNS servers: Consul DNS, AWS VPC DNS, > > Google DNS. It turns out that the AWS VPC DNS is the fastest to respond > and > > therefore causes results to fail even though they can be served via > Consul > > DNS. Putting aside that the musl resolver logic breaks convention (which > > many people rely on), it seems that in this case it is more unpredictable > > than simply following the order. > > > > The host DNS is Consul, and while we could just setup Consul with > > recursors, we run the risk of failing to resolve anything if Consul > fails. > > Setting up a local caching DNS is also overkill (we're in Docker > > containers). > > > > Is there no way to force musl to follow the order of nameservers in > > resolv.conf? Or even if not, to allow musl to accept the first successful > > response instead of failing on the first response? It seems to me that we > > have to give up reliability for predictability, which is not what this > > feature was intended to do from my understanding. > > > > Any help on this matter would be greatly appreciated! > > Someone else raised this question on our IRC channel a week or two > ago, and in short, the answer is no. Basically this setup does not > make sense, even if you do have a resolver (glibc) that does do > ordered fallback: > > - If you expect to sometimes need the second or third nameserver for > queries the first cannot answer, then you're going to have terrible > performance (multi-second delay before falling back to the second > one). > > - Unless all the nameservers agree on the records they're serving (in > which case you wouldn't care about order), your query results will > be unstable/inconsistent when the first server fails to respond. The > typical result is that you will wrongly get NxDomain instead of a > failed/timed-out query. > > The second issue is really the motivation for what musl is doing: musl > is assuming that all the nameservers have consistent records, because > if they didn't, actual positive/negative results would be affected by > transient failures rather than transient failures being reported to > the calling program. This is a serious class of robustness (and > possibly security, since DoS can translate into false results) > failure. > > If you really need to union inconsistent records from multiple > nameservers, the right way to do this is with a dns proxy/cache. > Assuming no _conflicting_ positive responses, it would need to do > something like forward positive responses as soon as it has at least > one positive response from upstream, but only forward negative > responses once it has a negative response from _all_ upstream sources. > Of course these are the constraints to do it "right"/robustly. If all > you want is something that works at least as well as glibc is working > for you now, dnsmasq is probably sufficient. > > The conversation about all this on IRC was actually quite interesting. > We have a no-public-logging policy so there are not logs posted > anywhere, but if you're interested in more of what was discussed I > could try to summarize it or see if the people involved would be ok > with sharing a log excerpt. > > Rich > --001a1134e2ec31370f051fc8b7b5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the response!

I would love t= o know more about the conversation on IRC.

I almos= t feel like there are valid arguments on both sides. In a distributed envir= onment, where machines and services come and go, it's pretty difficult = to guarantee consistent records both reliably and quickly.

While I was able to semi-solve my problem by enabling recursors th= rough Consul DNS, I realized that I have a chicken and egg problem. The cav= eat here is this is particular to docker and some of the decisions they'= ;ve made.

The basic issue is that I have some cont= ainers that need to be run with "--net=3Dhost" and some that do n= ot. In the "--net=3Dhost" containers effectively copy over the ho= st's resolv.conf. In order to make sure everything can be resolved, I n= eed to guarantee that Consul is setup as early as possible. However, in the= case that the setup process needs DNS, you run into a problem. I could do = some clever hackery to use the default host DNS and overwrite the host'= s /etc/resolv.conf after setting up Consul DNS, but that's not the grea= test solution. This problem can also occur with bridged-networking containe= rs if you choose to specify the "dynamic" DNS server as a default= dns option to the docker daemon.

Put in more simp= le terms, we need normal DNS resolution while bootstrapping, then as servic= es register themselves, we need dependent services to be able to look up th= e newly registered entries. Effectively, the consistency is delayed at best= .

The other issue here is that having recursion en= abled just feels wrong and insecure. Sure, this is all behind a VPC, but I = like to err on the side of caution.

I am probably wrong here, but it seem= s that the musl logic is only valid when all nameservers are consistent. Ho= wever, with dynamic service registration, that consistency comes at the cos= t of speed.

The behavior we would ideal= ly want is as you mentioned:
"Assuming no _conflicting_ positive responses, it woul= d need to do
something like forward positive responses as soon as it has at least
one positive response from upstream, but only = forward negative
responses once it has a n= egative response from _all_ upstream sources."

I'm almost certain we can acco= mplish what we want by having dnsmasq or some other dns proxy/cache try Con= sul DNS first and then fallback upstream for non-authoritative domains. The= proxy has to be available very early on, which is entirely doable in our s= cenario. However, it does add another layer of indirection, which is just a= nother potential failure point.

All that being said, I definitely understand why t= he decision was made, just would be nice to have an option to enable the &q= uot;robust" logic! :)

On Mon, Sep 14, 2015 at 9:43 PM Rich Felker <dalias@libc.org> wrote:
On Tue, Sep 15, 2015 at 03:25:20AM +0000,= Jameel Al-Aziz wrote:
> I'm sure this has been brought up before, but just thought I'd= reach out
> see if there's a solution.
>
> I use musl on Alpine via Docker. I encountered issues today where DNS<= br> > wasn't resolving the way we expect in our images. I finally manage= d to
> trace it down to musl's resolver (
> http://wi= ki.musl-libc.org/wiki/Functional_differences_from_glibc#Name_Resolver_.2F_D= NS
> ).
>
> We configure resolv.conf with three DNS servers: Consul DNS, AWS VPC D= NS,
> Google DNS. It turns out that the AWS VPC DNS is the fastest to respon= d and
> therefore causes results to fail even though they can be served via Co= nsul
> DNS. Putting aside that the musl resolver logic breaks convention (whi= ch
> many people rely on), it seems that in this case it is more unpredicta= ble
> than simply following the order.
>
> The host DNS is Consul, and while we could just setup Consul with
> recursors, we run the risk of failing to resolve anything if Consul fa= ils.
> Setting up a local caching DNS is also overkill (we're in Docker > containers).
>
> Is there no way to force musl to follow the order of nameservers in > resolv.conf? Or even if not, to allow musl to accept the first success= ful
> response instead of failing on the first response? It seems to me that= we
> have to give up reliability for predictability, which is not what this=
> feature was intended to do from my understanding.
>
> Any help on this matter would be greatly appreciated!

Someone else raised this question on our IRC channel a week or two
ago, and in short, the answer is no. Basically this setup does not
make sense, even if you do have a resolver (glibc) that does do
ordered fallback:

- If you expect to sometimes need the second or third nameserver for
=C2=A0 queries the first cannot answer, then you're going to have terri= ble
=C2=A0 performance (multi-second delay before falling back to the second =C2=A0 one).

- Unless all the nameservers agree on the records they're serving (in =C2=A0 which case you wouldn't care about order), your query results wi= ll
=C2=A0 be unstable/inconsistent when the first server fails to respond. The=
=C2=A0 typical result is that you will wrongly get NxDomain instead of a =C2=A0 failed/timed-out query.

The second issue is really the motivation for what musl is doing: musl
is assuming that all the nameservers have consistent records, because
if they didn't, actual positive/negative results would be affected by transient failures rather than transient failures being reported to
the calling program. This is a serious class of robustness (and
possibly security, since DoS can translate into false results)
failure.

If you really need to union inconsistent records from multiple
nameservers, the right way to do this is with a dns proxy/cache.
Assuming no _conflicting_ positive responses, it would need to do
something like forward positive responses as soon as it has at least
one positive response from upstream, but only forward negative
responses once it has a negative response from _all_ upstream sources.
Of course these are the constraints to do it "right"/robustly. If= all
you want is something that works at least as well as glibc is working
for you now, dnsmasq is probably sufficient.

The conversation about all this on IRC was actually quite interesting.
We have a no-public-logging policy so there are not logs posted
anywhere, but if you're interested in more of what was discussed I
could try to summarize it or see if the people involved would be ok
with sharing a log excerpt.

Rich
--001a1134e2ec31370f051fc8b7b5--