29

How many subdomains can you have on your domain? And with that, I mean levels of subdomains.

For example, you have the domain example.com, I know you can have test.example.com, but how many levels can you have? Like test2.test.example.com, test3.test2.test.example.com etc.

Second, I was wondering 2 things about email addresses. First of all, how common is the usage of subdomains in an email address (IF it's even possible)? I've never seen something like [email protected] to be honest so I'm not exactly sure. And if it's possible, how many levels (just like above) can you have?

And last, can the questions above depend on the domain registrar or the mail server etc.? And what could it depend on?

5
  • 2
    It's very common in countries like Australia and the UK which have .com.au and .co.uk to have three levels in the hostname in email addresses.
    – Nacht
    Commented Mar 30, 2017 at 2:42
  • 2
    @Nacht: Indeed, that can pretty easily get you to something like [email protected] Commented Mar 30, 2017 at 5:04
  • Yeah I forgot about that. How could I've forgot. I see .com and .nl too much I forgot about the other extensions like com.au, .co.uk etc etc. Commented Mar 30, 2017 at 9:50
  • 4
    For the record, I used to have an e-mail address @cgg.ms.mff.cuni.cz. Deep domain hierarchies are rather common in academia. Commented Mar 30, 2017 at 10:13
  • @Angew Oh, well I've never seen something like it so I didn't know it is possible. Commented Mar 30, 2017 at 10:14

1 Answer 1

42

There are no direct limits on how many levels i.e. dots you can have in a hostname. However, a RFC1034 compliant hostname can only be 255 bytes long, leaving 253 bytes for a fully qualified domain name FQDN in DNS. Some systems and TLS/SSL limits FQDN to 64 bytes and FQDN in emails should not exceed(*) 245 or 221 or 189 bytes depending on the maximum user name length (8, 32 or 64).

As TLD usually takes at least 2 characters and . and every part of the hostname must be at least one character long, the space left for additional dots i.e. theoretically maximal levels would be:

  • (253-3)/2 = 125 levels after TLD for theoretically longest (not so useful) hostname
  • (221-3)/2 = 109 or (189-3)/2 = 93 levels after TLD, if you wish to use it for email
  • (63-3)/2 = 30 levels after TLD, if you wish to use SSL/TLS.

And yes, [email protected] is in a valid email address format.


(*) The special limitation for email address length is a result of RFC 5321 4.5.3.1 and 4.1.2:

4.5.3.1.1.  Local-part

   The maximum total length of a user name or other local-part is 64
   octets.

4.5.3.1.3.  Path

   The maximum total length of a reverse-path or forward-path is 256
   octets (including the punctuation and element separators).

4.1.2 Command Argument Syntax

   Path           = "<" [ A-d-l ":" ] Mailbox ">"

As forward-path must include the angle brackets, only 254 characters are left for the email address. Then, the username@ part of 8(+1), 32(+1) or 64+1 must be excluded to get the maximum FQDN lenght.

4
  • 2
    RFC 1034 is where the upper limit on both the total length of the domain name (including all the subdomain parts) of 255 octets originates from and as well as the maximum length of 63 octets for a hostname/subdomain. Longer domain names should (rather than must) be supported as well per RFC 1123 but AFAIK those aren't really seen in the wild.
    – HBruijn
    Commented Mar 29, 2017 at 12:28
  • 1
    citation needed re: total length restriction of an email address.
    – Alnitak
    Commented Mar 29, 2017 at 20:17
  • The length isn't that important. I know with multiple subdomains the length automatically increases, however; the only thing important for me is the amount of subdomain levels you can have, as they won't be extremely long anyway. Also, 30 levels is not something I would even do. Not even 10. Maybe just 3/4 max. But it was also a big curiousity I had (note: I'm no expert on servers and domains). Commented Mar 30, 2017 at 9:48
  • Added argument and citation for maximum email address length, @Alnitak Commented Apr 8, 2017 at 14:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .