On Fri, May 6, 2016 at 5:50 AM, Yun Feng Ma <yunfen...@gmail.com> wrote: > 在此输入代码... > > > > 在 2016年5月6日星期五 UTC+8上午9:43:50,Ben Noordhuis写道: >> >> On Thu, May 5, 2016 at 9:00 AM, Yun Feng Ma <yunf...@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. > > > Thanks, Ben, for the reply. > > In our environment, the first nameserver is our internal DNS server, which > is used to resolve some internal domain names; the second nameserver is the > public nameserver (like google DNS server 8.8.8.8), so this code > dns.resolve('www.google.com','A',function(err, addresses) { }) will get > failed, because the first nameserver returns NXDOMAIN for "www.google.com". > Do you have any solution for this? > > Thanks.
Not a node.js-based solution but is there a reason you can't configure your internal nameserver to forward requests for names it doesn't know about to an upstream server? If that isn't a option, you could try installing dnsmasq locally and see if you can make it do what you want. -- 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_6spr2VfcW9fm2go8ySndHuZfm00o0aOJDpE11hGxMtA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.