Are there any limits to the character length of a service nam e in an SRV record?

Jim Reid jim at rfc1035.com
Mon Aug 30 20:55:26 UTC 2004


>>>>> "Todd" == Corsa, Todd <tcorsa at bnl.gov> writes:

    Todd> You're right, RFC 1035 could hardly be clearer about limits
    Todd> for domain names, but predates the concept of SRV records,
    Todd> and therefore service names, so I'm looking for clear
    Todd> guidelines.

Presumably your definition of service names means "the set of domain
names that can be assigned to SRV records". If so, these so-called
service names are domain names. They are therefore bound by the
fundamental protocol limits defined in RFC1035 that have already been
quoted to you. All domain names entered into the DNS must follow
RFC1035's rules. That's what makes them domain names. FWIW, RFC2782
suggests a service name is "The symbolic name of the desired service,
as defined in Assigned Numbers....": ie "_smtp", "_ftp", etc.

    Todd> If you're saying that a service name should just be treated
    Todd> like a FQDN, then that would answer my question. So that
    Todd> would mean that "_ldap._tcp.example.com" is a name
    Todd> consisting of 4 labels taking up 24 bytes broken down like
    Todd> this:

    Todd> One octet length field = 1 octet
    Todd> _ldap._tcp.example.com = 22 octets
    Todd> terminating null byte = 1 octet

Nope. Each *label* gets a byte count. Assuming no label compression,
the wire format for the name above would be 5_ldap4_tcp7example3com0.
That's a total of 24 bytes for 4 labels amounting to 19 bytes --
_ldap, _tcp, example & com -- and 5 label byte counts. It's a
convenient accident that your method of counting the length of the
domain name happened to arrive at the right total.

    Todd> So that would mean that a complete service name can contain
    Todd> no more than 253 characters, and that the "_Service" portion
    Todd> can be no more than 63 of the total characters, the "_Proto"
    Todd> portion can be no more than 63 of the total characters, and
    Todd> the "Name" portion must be a properly formatted domain name
    Todd> that can be no longer than 253 minus (_Service length) minus
    Todd> 1 (for the dot after _Service) minus (_Proto length) minus 1
    Todd> ( for the dot after _Proto) characters.

Not quite. Consider the domain name _S._P.F.Q.D.N which is the owner
name for some SRV record. None of the labels -- _S, _P, F, Q, D, N --
can be more than 63 bytes long. The maximum length of _S._P.F.Q.D.N is
255 bytes, including the protocol overhead. However the maximum number
of characters in _S._P.F.Q.D.N (including the dots) can't exceed 253.
One byte is needed for the byte count for the first label: _S. Each
dot in the domain name is replaced by the byte count for each of
the following labels. Another byte is needed for the terminating null
byte. The F.Q.D.N part of the domain name counts towards the overall
maximum length of _S._P.F.Q.D.N. F.Q.D.N can only be as long as:
	255 - (len(_S) +1) - (len(_P) +1) - 2
ie
	255 byte maximum
	- (number of bytes in label _S + 1 byte to encode its length)
	- (number of bytes in label _P + 1 byte to encode its length)
	- 2 for the terminating byte and 1 byte for first label length

You seem to think that the length of a domain name is in addition to
the length of your service names. That's not the case. These service
names -- whatever they are -- MUST be domain names in order to be
entered into the DNS. [Well duh-uh!] Therefore they have to conform to
the rules laid down in RFC1035.


More information about the bind-users mailing list