Date: Fri, 15 Oct 2004 09:58:05 -0700 (PDT) From: Rostislav Krasny <rosti_bsd@yahoo.com> To: freebsd-hackers@freebsd.org Subject: Fwd: default resolver(5) configuration and behavior of functions like gethostbyname(3) Message-ID: <20041015165805.62571.qmail@web14822.mail.yahoo.com>
next in thread | raw e-mail | index | archive | help
Hello everybody. About two weeks ago I've sent following email to the freebsd-net mailing list but I didn't get any reply of it yet. Could someone of you answer to my questions those I've asked in my original email? Thank you. --- Rostislav Krasny <rosti_bsd@yahoo.com> wrote: > From Rostislav Krasny Thu Sep 30 08:31:24 2004 > Thu, 30 Sep 2004 08:31:24 PDT > Date: Thu, 30 Sep 2004 08:31:24 -0700 (PDT) > From: Rostislav Krasny <rosti_bsd@yahoo.com> > Subject: default resolver(5) configuration and behavior of functions like > gethostbyname(3) > To: freebsd-net@freebsd.org > MIME-Version: 1.0 > Content-Type: text/plain; charset=us-ascii > Content-Length: 1462 > > Hello all. Please consider following two questions: > > 1. According to the resolver(5) manual page the default number of times > the > resolver will send a query to each of its name servers is defined as > RES_DFLRETRY in resolv.h standard header file. Actually there was no > RES_DFLRETRY in the resolv.h before following commits to HEAD made by Yar > Tikhiy: > > http://docs.freebsd.org/cgi/mid.cgi?200409091739.i89HdlwM019548 > http://docs.freebsd.org/cgi/mid.cgi?200409091742.i89HgIan019681 > http://docs.freebsd.org/cgi/mid.cgi?200409091719.i89HJRGu019026 > > This default number of retries (the RES_DFLRETRY macro in the HEAD and a > hardcoded constant value in 5.x) is 4. But in most of other UNIX or > UNIX-like systems (Solaris, AIX, Linux, NetBSD) this default value is 2. > Only in OpenBSD it is 4 and also it is a hardcoded constant there. > > Please explain why developers of FreeBSD had chose 4 instead of 2? Maybe > they should change it to 2, as this default value is defined on most of > other systems, including NetBSD? > > > 2. Please consider following experimets I did on FreeBSD 5.3-BETA2-BETA6: > > I changed the /etc/resolv.conf so it had only one following line: > > nameserver 21.21.21.21 > > 21.21.21.21 is just some black-hole host without any working DNS on it. > Then I ran 'tcpdump -nvi ed1' on one pseudo terminal and 'ping yahoo.com' > on other pseudo terminal. This way I counted the "A? yahoo.com." DNS > queries before ping(8) returned an error. With this configuration there > were 8 "A? yahoo.com." DNS queries. Then I added following line to the > /etc/resolv.conf > > options attempts:1 > > With this configuration there were 2 "A? yahoo.com." DNS queries. With > "attempts:2" there were 4 "A? yahoo.com." DNS queries, with "attempts:3" > there were 6 "A? yahoo.com." DNS queries, with "attempts:5" there were 10 > "A? yahoo.com." DNS queries and so on. > > I repeated this experiment with following program been used instead of > the > ping(8): > > #include <sys/types.h> > #include <sys/socket.h> > #include <netinet/in.h> > #include <arpa/inet.h> > #include <netdb.h> > #include <stdio.h> > > int main(void) > { > const char *name="yahoo.com"; > struct hostent *ps_hostent; > char **st; > > ps_hostent=gethostbyname(name); > if (ps_hostent!=NULL) { > printf("%s\n", ps_hostent->h_name); > for (st=ps_hostent->h_addr_list; *st!=NULL; st++) { > printf("%s\n", > inet_ntoa(*(struct in_addr *)*st)); > } > if (st==ps_hostent->h_addr_list) > fputs("It have no address.\n", stderr); > } else { > herror(name); > } > return 0; > } > > The results where exactly the same. > > Why the number of DNS queries is always doubled? With default resolver(5) > configuration there are 8 DNS queries to one non-working DNS server and > it takes 2:30 minutes before an error returned. IMHO this is too much > time and too much queries for default resolver(5) configuration. Who and > why is doubling the number of DNS queries? Is it gethostbyname(3) > function or the resolver itself? __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041015165805.62571.qmail>