Long domain names

This domain has a label with size 63 bytes:
one-of-the-longest-possible-dns-labels-with-63-ascii-characters.tyilo.com
Redirect: long.tyilo.com

This domain has a total length of 253 bytes:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc.ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd.tyilo.com
Redirect: longer.tyilo.com

See also: longestdomains.com

Explanation

A domain name consists of several labels separated with dots. Each label can have a size between 1 and 63 bytes (inclusive, only ASCII is allowed). A fully qualified domain name (FQDN) is basically a domain as you normally see them with a dot at the end.

For instance the FQDN version of example.org is example.org.

In a DNS query a domain is always queried with its FQDN, encoded in the following way:

bytes = []
for label in domain.fqdn_labels:
    bytes.push(len(label))
    bytes += label

For instance www.example.org (15 bytes) and www.example.org. (16 bytes) would both be encoded as the following 17 bytes:

3'w''w''w'7'e''x''a''m''p''l''e'3'o''r''g'0

The maxium size of an encoded FQDN in a DNS query is 255 bytes, so this results in the maximum domain name being 253 bytes (or 254 when including the final dot for the FQDN).