Is there a maximum subdomain depth?

Solution 1:

I believe the DNS itself can have up to 127 levels of label, each label can be up to 63 characters and the maximum length of the whole record is limited to 253 characters as you have to encode the length and a terminating 0.

Solution 2:

There is no defined maximum in terms of the number of dot-delimited subdomains, but DNS does limit the maximum overall length of a hostname (including the dots) to 255 characters.

Solution 3:

Due to rfc1035:

To simplify implementations, the total length of a domain name (i.e., label octets and label length octets) is restricted to 255 octets or less.

Also

Each label is represented as a one octet length field followed by that number of octets. Since every domain name ends with the null label of the root, a domain name is terminated by a length byte of zero

So, maximum valid length is 255-2 symbols (tested in DIG). Whole UDP message also should be less or equal 512 bytes. But that's not too small and makes IPoverDNS possible.