default resolver(5) configuration and behavior of functions like gethostbyname(3)

From: Rostislav Krasny (rosti_bsd_at_yahoo.com)
Date: 09/30/04

  • Next message: Andre Oppermann: "Re: if_bge with <Broadcom BCM5703 Gigabit Ethernet, ASIC rev. 0x1002>(was: Re: Strange things on GBit / 1000->100 /net.inet.tcp.inflight.* )"
    Date: Thu, 30 Sep 2004 08:31:24 -0700 (PDT)
    To: freebsd-net@freebsd.org
    
    

    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!?
    Declare Yourself - Register online to vote today!
    http://vote.yahoo.com
    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"


  • Next message: Andre Oppermann: "Re: if_bge with <Broadcom BCM5703 Gigabit Ethernet, ASIC rev. 0x1002>(was: Re: Strange things on GBit / 1000->100 /net.inet.tcp.inflight.* )"

    Relevant Pages