Hey.

Recently I've heard that some people tend to see domain levelling quite different than the others.
I found it quite an interesting thing to check, that's why I'm writing this article.

Everybody knows that com, net, org are so called TLDs (Top-Level-Domains) and that they are part of the . (root) tree.
Not everybody knows that actually in the very prehistoric times, the notation was com. net. org. as to indicate that they have the root parent.
But that's only for curiosity.

Ok, so let's elaborate a bit...

Let's take into account domain testdomain.com.
How many levels does this domain have? Two. Right.
First level is com, the second is testdomain.
That's quite obvious, isn't it?

Let's go further then. Copy, paste:

Let's take into account domain mysubdomain.testdomain.com.
How many levels does this domain have? Three. Right again!

.com
   |->.testdomain
        |-> .mysubdomain

True. So what's the problem? Here it is.

Let's take www.mysubdomain.testdomain.com.
How many levels does it have? 4? Right. 3? Wrong.
Some people tend to say that this is still a 3rd level domain. Why? I think I know why and here's the explanation.

I don't want to go into how DNS works but:

Let us assume that www.mysubdomain.testdomain.com resolves with DNS to 1.2.3.4.
Right. That means it has an A record in DNS for zone mysubdomain.testdomain.com. Right? Wrong.
It can have. But it can have a CNAME record as well.
That's the confusion. Some people tend to say that www here is an alias. An alias then, is actually a CNAME record, that is pointing to an A record (that does actually point the IP address).

The point is. It does not matter what record in the DNS you have, CNAME or A. It is still a valid DNS record, and if it designates another subdomain (yes, www here is a subdomain, it's not delegated though with NS record, but pointing to a specific IP address with A record), then it is separated with a '.' (dot) sign. Though it starts to be n+1 level in the hierarchic system.

To say more, here are the examples of some weird (but sometimes useful) entries in the DNS system (this is for testdomain.com still):

www IN A 1.2.3.4

meaning www.testdomain.com is under 1.2.3.4 (3 level domain)

www2 IN CNAME www

meaning www2.testdomain.com is under www.testdomain.com (that is under 1.2.3.4) (still 3 level)

www.dev IN A 5.4.3.2

meaning www.dev.testdomain.com is under 5.4.3.2. Yes, this is a four-level-domain.

otherdomain.testdomain.com IN NS 100.100.100.1

meaning 3rd level domain otherdomain.testdomain.com is delegated to a nameserver at ip 100.100.100.1.

If you are not convinced yet, then here are some RFC proofs:

RFC2606:

The global Internet Domain Name System is documented in [RFC 1034,
1035, 1591] and numerous additional Requests for Comment. It defines
a tree of names starting with root, ".", immediately below which are
top level domain names such as ".com" and ".us". Below top level
domain names there are normally additional levels of names.

http://en.wikipedia.org/wiki/Domain_name#Other-level_domains

In addition to the top-level domains, there are second-level domain (SLD) names. These are the names directly to the left of .com, .net, and the other top-level domains. As an example, in the domain en.wikipedia.org, "wikipedia" is the second-level domain.</p>

On the next level are third-level domains. These domains are immediately to the left of a second-level domain. In the en.wikipedia.org example, "en" is a third-level domain. There can be fourth and fifth level domains and so on, with virtually no limitation. An example of a working domain with five levels is www.sos.state.oh.us. Each level is separated by a dot or period symbol between them.

Domains of third or higher level are also known as subdomains, though this term technically applies to a domain of any level, since even a top-level domain is a "subdomain" of the "root" domain (a "zeroth-level" domain that is designated by a dot alone).

Traditionally, the second level domain was the name of the company or the name used on the internet. The third level was commonly used to designate a particular host server. Therefore, ftp.wikipedia.org might be an FTP server, www.wikipedia.org would be a World Wide Web Server, and mail.wikipedia.org could be an email server. Modern technology now allows multiple servers to serve a single subdomain, or multiple protocols or domains to be served by a single computer. Therefore, subdomains may or may not have any real purpose.

RFC1034:

When a user needs to type a domain name, the length of each label is
omitted and the labels are separated by dots ("."). Since a complete
domain name ends with the root label, this leads to a printed form which
ends in a dot. We use this property to distinguish between:</p>

- a character string which represents a complete domain name
(often called "absolute"). For example, "poneria.ISI.EDU."

- a character string that represents the starting labels of a
domain name which is incomplete, and should be completed by
local software using knowledge of the local domain (often
called "relative"). For example, "poneria" used in the
ISI.EDU domain.

Relative names are either taken relative to a well known origin, or to a
list of domains used as a search list. Relative names appear mostly at
the user interface, where their interpretation varies from
implementation to implementation, and in master files, where they are
relative to a single origin domain name. The most common interpretation
uses the root "." as either the single origin or as one of the members
of the search list, so a multi-label relative name is often one where
the trailing dot has been omitted to save typing.

To simplify implementations, the total number of octets that represent a
domain name (i.e., the sum of all label octets and label lengths) is
limited to 255.

A domain is identified by a domain name, and consists of that part of
the domain name space that is at or below the domain name which
specifies the domain. 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.
For example, A.B.C.D is a subdomain of B.C.D, C.D, D, and " ".</div>