Search code examples
httpsubdomain

What is the "subdomain" and "subdomains" in hostname with more than 3 levels?


This terminology is critical for the variables naming in the subdomains analyzing library.

enter image description here

  • If each of a_1 and a_2 is the "subdomain", the b_1 will be the "subdomains", but it this case what will be in XXX placeholder of "b_1 and b_2 are XXX"?
  • If each of b_1 and b_2 is the "subdomain", the b_1 and b_2 are "subdomains`, but in this case what will be in XXX placeholder of "each of a_1, a_2 and and b_3 is the XXX"?

Solution

  • If you need the right terminology, there is only one good source right now:

    RFC 8499 DNS Terminology

    TL;DR: any domain is a subdomain of any other domain (except the root), and a subdomain is also a domain.

    A string is neither or both depending on how you look at it. The "sub" part comes only when you compare things.

    But back to the RFC you can read:

    Subdomain: "A domain is a subdomain of another domain if it is contained within that domain. This relationship can be tested by seeing if the subdomain's name ends with the containing domain's name." (Quoted from [RFC1034], Section 3.1) For example, in the host name "nnn.mmm.example.com", both "mmm.example.com" and "nnn.mmm.example.com" are subdomains of "example.com". Note that the comparisons here are done on whole labels; that is, "ooo.example.com" is not a subdomain of "oo.example.com".

    In your case:

    • foo.example.com is a subdomain of example.com
    • en.foo.example.com is a subdomain both of foo.example.com and example.com.

    Note that there is an important point often forgotten in all of this: dots separate labels but do not map 1:1 to zone cut or administrative changes. Just looking at a name, like en.foo.example.com you can NOT know if en.foo.example.com is managed by same company/DNS infrastructure than foo.example.com or example.com or com even.

    You can find that out only by doing live DNS queries or using heuristics such as the Public Suffix List.

    As for:

    This terminology is critical for the variables naming in the subdomains analyzing library.

    Strong suggestion: DO NOT use the term "subdomain". A name is a list of labels, and you can manage things that way (that is a list in your language of choice). That is the only thing that matter that you can derive trivially from just looking at the string, without anything else to compare it with. (pro-tip: be cautious about possible final dots in names as well as case, but this also depends on if you have to handle IDNs or not).