[DragonFlyBSD - Bug #3294] drill(1) with IPv6 NS fails with UDP but works with TCP

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Mon Oct 25 07:45:08 PDT 2021

Issue #3294 has been updated by y0n3t4n1.

I spent some time playing with LDNS example code and comparing the net.c with resolv/res_send.c in libc, and found that LDNS sends the query with sendto, while the libc resolver uses connect+send, unless RES_INSECURE1 is specified.

So with the code at the bottom of this comment, this succeeds
./r aaaa leaf.dragonflybsd.org.
while this fails
./r -1 aaaa leaf.dragonflybsd.org.

#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <err.h>
#include <errno.h>
#include <resolv.h>
#include <stdio.h>
#include <unistd.h>

int main(int ac, char **av)
        u_char answer[1024];
        int ch;
        const char *me = av[0];

        if (res_init() != 0)
                err(-1, "res_init");
        while ((ch = getopt(ac, av, "12t")) != -1) {
                switch (ch) {
                case '1':
                        _res.options |= RES_INSECURE1;
                case '2':
                        _res.options |= RES_INSECURE2;
                case 't':
                        _res.options |= RES_USEVC;
                        errx(-1, "unknown switch %c", ch);
        ac -= optind, av += optind;
        if (ac < 2)
                errx(-1, "usage: %s resource type domain...", me);

        int ok = 0;
        int query_type = res_nametotype(*av, &ok);
        if (!ok)
                errx(-1, "unknown query type: %s", *av);

        fp_resstat(&_res, stdout);
        while (++av, --ac > 0) {
                int l = res_query(*av, C_IN, query_type, answer, sizeof answer);
                if (l == -1) {
                        warnx("res_query: %s", *av);
                res_pquery(&_res, answer, l, stdout);

Bug #3294: drill(1) with IPv6 NS fails with UDP but works with TCP

* Author: liweitianux
* Status: New
* Priority: Normal
* Target version: 6.2
* Start date: 2021-08-13
YONETANI Tomokazu reported this issue on users@ mailing list: https://lists.dragonflybsd.org/pipermail/users/2021-August/404805.html

$ drill  @2001:4860:4860::8888 aaaa leaf.dragonflybsd.org | egrep -v
Error: error sending query: Could not send or receive, because of network

unless using TCP query:

$ drill -t @2001:4860:4860::8888 aaaa leaf.dragonflybsd.org | egrep -v
leaf.dragonflybsd.org. 3599 IN AAAA 2001:470:1:43b:1::68

Similar DNS queries on other boxes running different OSes don't have the same problem, and tcpdump output shows the response from the DNS server, so I doubt it's an network issue.

$ uname -a
DragonFly c60 6.0-RELEASE DragonFly v6.0.0.33.gc7b638-RELEASE #0: Wed Aug 4
20:25:25 JST 2021 root at c60:/usr/obj/build/usr/src/sys/X86_64_GENERIC x86_64


I also confirmed this issue on leaf, which running master as of Aug 4.

You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account

More information about the Bugs mailing list