Requesting A and AAAA records in single DNS query Requesting A and AAAA records in single DNS query c c

Requesting A and AAAA records in single DNS query


I'm not aware of any nameservers that support multiple questions in a single query.

There's potential for ambiguity in such a query, since there are per-packet flags (such as AA) which could apply to only one of the questions. If you ask two questions and the server is authoritative for only one of the domains, should the server set the flag or not? I suspect issues such as these have deterred implementors.

There have been a number of proposals to solve the problem you're talking about (such as this proposal to introduce a QTYPE that combines A and AAAA, and Paul Vixie's repeated attempts to introduce an EDNS form of multiple questions), but at present programs supporting both IPv4 and 6 tend to perform two separate queries, either AAAA followed (after a timeout) by A, or both simultaneously.

I suppose there's also the "all" QTYPE, but it can return a lot more data than you need.

Edit: from query.c in the BIND source:

   dns_message_currentname(message, DNS_SECTION_QUESTION,         &client->query.qname);   client->query.origqname = client->query.qname;   result = dns_message_nextname(message, DNS_SECTION_QUESTION);   if (result != ISC_R_NOMORE) {     if (result == ISC_R_SUCCESS) {       /*        * There's more than one QNAME in the question        * section.        */       query_error(client, DNS_R_FORMERR, __LINE__);     } else       query_error(client, result, __LINE__);     return;   }

Edit: also, from resolver.c in the BIND source:

    /*     * XXXRTH  Currently we support only one question.     */    if (message->counts[DNS_SECTION_QUESTION] != 1) {            log_formerr(fctx, "too many questions");            return (DNS_R_FORMERR);    }


Whilst the packet format technically supports having more than one record in the question section (see ยง4.1.2 of RFC 1035), in practise it just doesn't work, as you've found.

In particular no-one has ever managed to define correct semantics for what to do if the two questions were to result in two different RCODEs.

I've tried to define those semantics at the IETF but as yet that hasn't got very far.

In my own DNS packet parsing code I always reject any such packet.


A and AAAA queries can be compined in a single packet, so my guess is that your packet is still malformed in some way, especially considering that queries do not use offsets into each others data. I would really help if you could show your actual code, or at least the raw bytes that you are sending.