On Thu, May 5, 2016 at 9:00 AM, Yun Feng Ma <yunfen...@gmail.com> wrote: > Hi everyone! > > The dns.resolve tries to send request to only the first nameserver in > /etc/resolv.conf, and if the first nameserver fails to resolve the name, > dns.resolve just returns and doesn't try to send request to the second > nameserver. Is this work-as-design? > > Here is an example: the /etc/resolv.conf is like below in Linux: > 75.2.4.5 > 75.4.7.6 > > Run below codes: > dns.resolve('demo1.sample.com','A',function(err, addresses) { > console.log(err); > console.log(addresses); > }); > > The 'demo1.sample.com' is defined in the second nameserver (75.4.7.6), so > the above codes always failed, because the dns.resolve doesn't try to call > the second nameserver. > > I found nodejs has flag to control this: > https://github.com/nodejs/node/blob/master/deps/cares/src/ares_init.c#L255 > seems like the default behaviour is only call the first nameserver, is there > any way to make dns.resolve to call all nameservers in /etc/resolv.conf > until succeed? > > Thanks a lot.
The second nameserver is only tried when the first one times out or returns a malformed reply. If the first server replies with NXDOMAIN (domain not found), the second one isn't contacted; that shouldn't be necessary because DNS is a global registry after all. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAHQurc-e2fBqd_h0TvFOtLZi-gobETfCFt1ShU1vuRp%2BWm4b%2BA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.