22

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 test@test.example.com 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?

  • 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 Mar 30 '17 at 2:42
  • 2
    @Nacht: Indeed, that can pretty easily get you to something like smith@foonly.maths.ox.ac.uk – Nate Eldredge Mar 30 '17 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. – Joshua Bakker Mar 30 '17 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. – Angew Mar 30 '17 at 10:13
  • @Angew Oh, well I've never seen something like it so I didn't know it is possible. – Joshua Bakker Mar 30 '17 at 10:14
32

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 bytes depending on the maximum user name length (8 or 32).

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 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, user@subdomainof.subdomain.example.com is in a valid email address format.


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

4.5.3.1 Size limits and minimums

   path
      The maximum total length of a reverse-path or forward-path is 256
      characters (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) or 32(+1) must be excluded to get the maximum FQDN lenght.

  • 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 Mar 29 '17 at 12:28
  • 1
    citation needed re: total length restriction of an email address. – Alnitak Mar 29 '17 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). – Joshua Bakker Mar 30 '17 at 9:48
  • Added argument and citation for maximum email address length, @Alnitak – Esa Jokinen Apr 8 '17 at 14:35

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.