Change in res_nsearch behaviour?

Cricket Liu cricket at
Tue Jan 25 14:28:39 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
> 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,
>                                          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.

> (I found this to be a useful feature when one has multiple
> subdomains to resolve hostnames of other subdomains).
> Is this an expected behaviour or a bug? Or Did I misunderstand
> something?

It's not only expected; it's fairly well documented.


Acme Byte & Wire
cricket at

Attend the next Internet Software Consortium/Acme Byte & Wire
DNS and BIND class!  See for
the schedule and to register for upcoming classes.

More information about the bind-workers mailing list