Change in res_nsearch behaviour?
muthu at wipro.wipsys.soft.net
Wed Jan 26 08:36:19 UTC 2000
> > Is there any reason behind the changed behaviour of res_nsearch?
> > In BIND 8.2.x (including 8.2.2-P5), the function res_nsearch does not do
> > any searching if there is a dot in the name. It tries the name 'as is' and
> > returns. It does not seem to be doing the search in the current/parent
> > domains if the 'as is' query failed. But according to the man page (ndots
Just make a note of this phrase. Please see below for my comments.
> > option), the 'search list' elements will be appended.
> No, according to the man page, if there are at least ndots in the domain
> name being looked up, the domain name will be looked up as-is
> *before* applying the search list.
> The idea, as I understand it, is that if someone types in a domain name
> argument with at least one dot in it, they've probably typed a fully
> qualified domain name, so the resolver routines should try it as-is
> > Here is the code from BIND 8.2.2-P5 res_nsearch() (line no. 210 of
> > res_query.c):
> > /*
> > * If there are enough dots in the name, do no searching.
> > * (The threshold can be set with the "ndots" option.)
> > */
> > if (dots >= statp->ndots || trailing_dot)
> > return (res_nquerydomain(statp, name, NULL, class, type,
Please note this one too.
> > answer, anslen));
> You missed this relevant code later in the same file:
> * We do at least one level of search if
> * - there is no dot and RES_DEFNAME is set, or
> * - there is at least one dot, there is no trailing dot,
> * and RES_DNSRCH is set.
Actually, I did not miss this code. My question is whether the
control can ever reach this part of the code IF THE 'AS IS' QUERY WAS NOT
If there is a dot in the name, it is tried 'as is' first. If the
query is successful, it will be returned to the caller. So far no problem.
But what happens if the 'as is' query failed (for e.g.: NO SUCH HOST**).
Because of the 'return' statement, the error too will be returned to the
caller without doing the search (whereas it is expected to do the search
in the current/parent domains).
If you see the old code (pre 8.2.x), control falls thru to the code
(which does the searching) if the 'as is' query failed, since there is a check
on the return value of res_querydomain().
I hope my understanding is correct.
So, with the newer code, if there is a dot in the name, it is tried
'as is' and the result returned (no searching in the current/parent
domains). This is what I called 'change in the behaviour of res_nsearch'
since I don't know whether the behaviour was intentionally changed or a
** For e.g.: assuming two subdomains test1 & test2 for isc.org and the search
list (on host1.test1.isc.org) as follows:
search test1.isc.org isc.org
Let us further assume that I want to resolve host2.test2.isc.org from host1.
So if I type,
it will be tried 'as is' first. This will return an error. Because
of the search list, the next query will be host2.test2.test1.isc.org (append
current domain). This too will fail. Now the next query will be
host2.test2.isc.org (append the parent domain) and I will get the correct
response for my query.
More information about the bind-workers