[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC 2181: What is the maximum length of a domain name?



It is well-known that the maximum length of a domain name is 255 octets.

It sounds simple, but what is included in that count?

* Is it the conventional API representation of the name, with text and 
separator dots? Is the final trailing dot included?

* Or is it the on-the-wire representation of the name, with length bytes 
and data bytes? Is the final null root label included?

To illustrate, is the length of "apple.com" considered to be 9, 10 or 11?

(A) Text representation, as commonly written with no trailing dot:
    "apple.com"
    Length = 9

(B) Text representation, with trailing dot:
    "apple.com."
    Length = 10

(C) On-the-wire representation, excluding terminator:
    -----------------------------------------------
    | 0x05 | a | p | p | l | e | 0x03 | c | o | m |
    -----------------------------------------------
    Length = 10

(D) On-the-wire representation, as it actually appears in a packet,
    including final null root label:
    ------------------------------------------------------
    | 0x05 | a | p | p | l | e | 0x03 | c | o | m | 0x00 |
    ------------------------------------------------------
    Length = 11

RFC 1034 seems relatively clear:

>To simplify implementations, the total number of octets that represent a
>domain name (i.e., the sum of all label octets and label lengths) is
>limited to 255.

While this certainly could be more specific, with a little thought it 
seems clear that the LEN("apple.com")=11 interpretation is the correct 
one:

1. The RFC 1034 text above says that *all* label octets and label lengths 
are included in the count. The final 0x00 is the label length byte for 
the zero-length root label at the end, so it is included in the count.

2. The RFC 1034 text above says "the total number of octets that 
represent a domain name". The final 0x00 is an essential part of how you 
represent a domain name in a packet -- if you try to omit it, then it 
won't work. Therefore it is included in the count.

If the intent of RFC 1034 were really to say, "The total number of octets 
that represent a domain name, not counting the final zero," then I think 
it would have said that explicitly. I don't think it is reasonable to 
assume, "Not counting the final zero," unless the text actually says that.

So far, so good. The text could have been clearer, but I think we have 
discerned the correct meaning.

Unfortunately, RFC 2181 "Clarifications to the DNS Specification" 
contradicts this:

>   A full domain
>   name is limited to 255 octets (including the separators).  The zero
>   length full name is defined as representing the root of the DNS tree,
>   and is typically written and displayed as ".".

What is "The zero length full name"? The shortest possible name is just 
one byte long: a single zero byte. That's one byte, not zero bytes. You 
can't put a zero-byte name into a DNS packet.

RFC 1034 is talking about the on-the-wire representation, with length 
bytes and data bytes.

RFC 2181 is talking about the conventional API representation of the 
name, with text and separator dots. RFC 2181 also describes the root 
name, ".", as the "zero length full name", implying that the final dot in 
any name is not counted. This would appear to support the 
LEN("apple.com")=9 interpretation.

There's a discrepancy of *two* between RFC 1034 and RFC 2181.

My current code uses the RFC 1034 interpretation (the total number of 
octets that it takes to represent a domain name in a packet, including 
all label length octets, all label data octets, and the label length 
octet for the terminating root label, so that LEN("apple.com")=11). 
Having given this some thought, I believe this is the correct 
interpretation of RFC 1034, but I'm willing to listen to arguments.

Comments?

Stuart Cheshire <cheshire@apple.com>
 * Wizard Without Portfolio, Apple Computer, Inc.
 * www.stuartcheshire.org


--
to unsubscribe send a message to namedroppers-request@ops.ietf.org with
the word 'unsubscribe' in a single line as the message text body.
archive: <http://ops.ietf.org/lists/namedroppers/>