<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.39 (Ruby 3.4.9) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-jabley-dnsop-ordered-answer-section-01" category="std" consensus="true" submissionType="IETF" updates="10341035" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.34.0 -->
  <front>
    <title>Ordering of RRSets in DNS Message Sections</title>
    <seriesInfo name="Internet-Draft" value="draft-jabley-dnsop-ordered-answer-section-01"/>
    <author fullname="Joe Abley">
      <organization>Cloudflare</organization>
      <address>
        <email>jabley@cloudflare.com</email>
      </address>
    </author>
    <author fullname="Sebastiaan Neuteboom">
      <organization>Cloudflare</organization>
      <address>
        <email>sebastiaan@cloudflare.com</email>
      </address>
    </author>
    <date year="2026" month="August" day="06"/>
    <area>Operations and Management</area>
    <workgroup>Domain Name System Operations</workgroup>
    <keyword>dns</keyword>
    <keyword>dns protocol</keyword>
    <keyword>dns message</keyword>
    <abstract>
      <?line 58?>

<t>The existing Domain Name System (DNS) specifications lack some
clarity in their description of the process by which individual
sections of a DNS message are constructed.</t>
      <t>This document updates RFC 1034 and RFC 1035 to provide a clearer
specification, consistent with deployed implementations.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="https://ableyjoe.github.io/draft-jabley-dnsop-ordered-answer-section/draft-jabley-dnsop-ordered-answer-section.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-jabley-dnsop-ordered-answer-section/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        Domain Name System Operations Working Group mailing list (<eref target="mailto:dnsop@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/dnsop/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/dnsop/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/ableyjoe/draft-jabley-dnsop-ordered-answer-section"/>.</t>
    </note>
  </front>
  <middle>
    <?line 68?>

<section anchor="introduction">
      <name>Introduction</name>
      <t><xref target="RFC1034"/> specifies an algorithm to follow when constructing
a response to a DNS QUERY.  This algorithm in some cases can result
in multiple RRSets being included in a single section of a DNS
message, e.g. when handling CNAME resource records.</t>
      <t>Most consumers of DNS responses, such as stub resolvers, have interpreted the
direction to copy or store particular RRSets in sections of a DNS
response to mean "append", treating each section as an ordered list
of RRSets.  In particular, many stub stub resolvers are known to rely upon
that interpretation when processing DNS responses, e.g. see <xref target="cloudflare"/>.</t>
      <t>Some DNS implementations employ algorithms in other sections that aim
to optimise processing of responses received by initiators, e.g.
NAPTR before SRV before A/AAAA in the additional section of a
response.  This behaviour has not been observed to cause any
interoperability problems, and is explicitly permitted by this
document.</t>
      <t>This document updates <xref target="RFC1035"/> to specify that the answer section in a
DNS message is an ordered list of RRSets, but that other sections may be
ordered differently. This document clarifies the directions
provided in <xref target="RFC1034"/> to match the observed behaviour and
expectations of deployed software.</t>
    </section>
    <section anchor="conventions-and-definitions">
      <name>Conventions and Definitions</name>
      <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>
      <?line -18?>

<t>This document assumes familiarity with terminology specific to the Domain Name System
(DNS) as described in <xref target="RFC9499"/>.</t>
    </section>
    <section anchor="rfc1034_updates">
      <name>Updates to RFC 1034</name>
      <t><xref target="RFC1034"/> specifies the algorithms by which sections of a DNS
response are constructed.  For example, step 3 of the
algorithm described in <xref target="RFC1034"/> section 4.3.2 contains the direction
"copy all RRs which match QTYPE into answer section".</t>
      <t>In this case, and in all other cases where <xref target="RFC1034"/> specifies that
particular RRSets be included in the answer section of a DNS message, the
section <bcp14>MUST</bcp14> be treated as an ordered list of RRSets.  When it is
necessary to include new RRSets in a section of a DNS message that is
under construction, those RRSets <bcp14>MUST</bcp14> be appended. The receiver of a
DNS message <bcp14>MAY</bcp14> refuse to process DNS messages that have been constructed
differently.</t>
      <t>When constructing other sections of a DNS message, each section <bcp14>MAY</bcp14> be
treated as a non-ordered list. A receiver of a DNS message <bcp14>MUST NOT</bcp14>
reject a DNS message on the basis of the order of RRSets in those sections.</t>
    </section>
    <section anchor="rfc1035_updates">
      <name>Updates to RFC 1035</name>
      <t>In a DNS message, the answer section <bcp14>MUST</bcp14> be considered to be an ordered
set of RRSets. All other sections in a DNS message <bcp14>MUST</bcp14> be considered to
be a non-ordered set.</t>
      <t>DNS implementations <bcp14>MUST</bcp14> construct each section in a DNS response
according to the algorithms specified in <xref target="RFC1034"/>, as clarified in
<xref target="rfc1034_updates"/>.</t>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>The recommendations contained in this document have no known security
implications.</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>This document has no IANA actions.</t>
    </section>
  </middle>
  <back>
    <references anchor="sec-combined-references">
      <name>References</name>
      <references anchor="sec-normative-references">
        <name>Normative References</name>
        <reference anchor="RFC1034">
          <front>
            <title>Domain names - concepts and facilities</title>
            <author fullname="P. Mockapetris" initials="P." surname="Mockapetris"/>
            <date month="November" year="1987"/>
            <abstract>
              <t>This RFC is the revised basic definition of The Domain Name System. It obsoletes RFC-882. This memo describes the domain style names and their used for host address look up and electronic mail forwarding. It discusses the clients and servers in the domain name system and the protocol used between them.</t>
            </abstract>
          </front>
          <seriesInfo name="STD" value="13"/>
          <seriesInfo name="RFC" value="1034"/>
          <seriesInfo name="DOI" value="10.17487/RFC1034"/>
        </reference>
        <reference anchor="RFC1035">
          <front>
            <title>Domain names - implementation and specification</title>
            <author fullname="P. Mockapetris" initials="P." surname="Mockapetris"/>
            <date month="November" year="1987"/>
            <abstract>
              <t>This RFC is the revised specification of the protocol and format used in the implementation of the Domain Name System. It obsoletes RFC-883. This memo documents the details of the domain name client - server communication.</t>
            </abstract>
          </front>
          <seriesInfo name="STD" value="13"/>
          <seriesInfo name="RFC" value="1035"/>
          <seriesInfo name="DOI" value="10.17487/RFC1035"/>
        </reference>
        <reference anchor="RFC2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author fullname="S. Bradner" initials="S." surname="Bradner"/>
            <date month="March" year="1997"/>
            <abstract>
              <t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>
        <reference anchor="RFC8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author fullname="B. Leiba" initials="B." surname="Leiba"/>
            <date month="May" year="2017"/>
            <abstract>
              <t>RFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
        <reference anchor="RFC9499">
          <front>
            <title>DNS Terminology</title>
            <author fullname="P. Hoffman" initials="P." surname="Hoffman"/>
            <author fullname="K. Fujiwara" initials="K." surname="Fujiwara"/>
            <date month="March" year="2024"/>
            <abstract>
              <t>The Domain Name System (DNS) is defined in literally dozens of different RFCs. The terminology used by implementers and developers of DNS protocols, and by operators of DNS systems, has changed in the decades since the DNS was first defined. This document gives current definitions for many of the terms used in the DNS in a single document.</t>
              <t>This document updates RFC 2308 by clarifying the definitions of "forwarder" and "QNAME". It obsoletes RFC 8499 by adding multiple terms and clarifications. Comprehensive lists of changed and new definitions can be found in Appendices A and B.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="219"/>
          <seriesInfo name="RFC" value="9499"/>
          <seriesInfo name="DOI" value="10.17487/RFC9499"/>
        </reference>
      </references>
      <references anchor="sec-informative-references">
        <name>Informative References</name>
        <reference anchor="Neuteboom2026" target="https://blog.cloudflare.com/cname-a-record-order-dns-standards/">
          <front>
            <title>What came first: the CNAME or the A record?</title>
            <author initials="S." surname="Neuteboom" fullname="Sebastiaan Neuteboom">
              <organization>Cloudflare</organization>
            </author>
            <date year="2026" month="January" day="14"/>
          </front>
        </reference>
        <reference anchor="Cisco2026" target="https://www.cisco.com/c/en/us/support/docs/smb/switches/Catalyst-switches/kmgmt3846-cbs-reboot-with-fatal-error-from-dnsc-process.html">
          <front>
            <title>Cisco Business Switches Reboot with Fatal Error from DNSC Process</title>
            <author>
              <organization>Cisco</organization>
            </author>
            <date year="2026" month="January" day="08"/>
          </front>
        </reference>
      </references>
    </references>
    <?line 165?>

<section anchor="cloudflare">
      <name>Events of 8 January 2026</name>
      <t>Cloudflare operates a well-known public DNS resolver known as
1.1.1.1, after one of the IPv4 addresses associated with the service.
On 8 January a software change in the 1.1.1.1 service had the
unintential side-effect of changing the order in which RRSets were
encoded in the answer section of DNS responses, in the case where
constructing the responses involved CNAME processing. The previous
ordering was as clarified in <xref target="rfc1034_updates"/> and <xref target="rfc1035_updates"/>. The change in behaviour
was not detected by a corresponding failure in a regression test,
since the ordering in the answer section was not considered to be
significant.</t>
      <t>Following the software release, Cloudflare became aware of significant
numbers of deployed DNS client implementations that were suffering
from failure. In particular, the getanswer_r() function invoked by
the getaddrinfo() function in glibc was found to fail to function,
and some deployed ethernet switches were observed to reboot when
trying to resolve the names of configured NTP servers <xref target="Cisco2026"/>.</t>
      <t>The impact associated with this event was particularly widespread
because of the widespread use of the 1.1.1.1 resolver. However, the
two examples of client implementations are also widely deployed in
systems that may well be upgraded only infrequently (or never
upgraded at all).</t>
      <t>See <xref target="Neuteboom2026"/> for additional information.</t>
    </section>
    <section anchor="editorial-notes-remove-before-publication">
      <name>Editorial Notes (remove before publication)</name>
      <section anchor="draft-jabley-dnsop-ordered-sections-00">
        <name>draft-jabley-dnsop-ordered-sections-00</name>
        <t>Initial draft circulated for comment in 2015; subsequently expired.</t>
      </section>
      <section anchor="draft-jabley-dnsop-ordered-answer-section-00">
        <name>draft-jabley-dnsop-ordered-answer-section-00</name>
        <t>Draft revitalised following some operational excitement.</t>
        <t>Added competent co-author.</t>
      </section>
      <section anchor="draft-jabley-dnsop-ordered-answer-section-01">
        <name>draft-jabley-dnsop-ordered-answer-section-01</name>
        <t>Bumped version number while we wait patiently for wg time.</t>
      </section>
    </section>
    <section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>The contributions of Mark Andrews and Paul Vixie to the original
revision of this document are acknowledged.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA5VZ7XLbNhb9j6fAKn+SjilFie0m3m5bxXa27sQftZ1mMjs7
HYiEJNQkoQVAK1pP3mWfZZ9sz70AqQ8rmazbiUQSBO4999xzL6Asy0QwodRH
snfpCu1MPZV2Iq+vb3Tw0tTy5OJGnmvv1VTLG50HY2vfE7kKemrd8kj6UIhm
XuDaH8nh85f7e/jnQIjC5rWqMG/h1CRkf6pxqZdZUXs7zyytpItM1X6hXebj
tNnzofDNuDLe4yos53j57PT2rZRPpCq9hYmmLvRc45869PZkTxcmWGdUSRdn
ozf4sA7frm/f9kT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