Is a CNAME to CNAME chain allowed?

Solution 1:

From RFC 1034 - Domain names - concepts and facilities:

Domain names in RRs which point at another name should always point at the primary name and not the alias. This avoids extra indirections in accessing information. For example, the address to name RR for the above host should be:

52.0.0.10.IN-ADDR.ARPA  IN      PTR     C.ISI.EDU

rather than pointing at USC-ISIC.ARPA. Of course, by the robustness principle, domain software should not fail when presented with CNAME chains or loops; CNAME chains should be followed and CNAME loops signalled as an error.

So yes, it is allowed and properly written software will handle it just OK. CNAME chains aren't however considered good practice and impose an overhead on the infrastructure.

Solution 2:

Sure, it is possible.

It is generally discouraged though, for the obvious reason that it uses more DNS resources. For example:

foo   IN      CNAME  someserver.somehost.com.
bar   IN      CNAME  foo

Querying 'bar' would result in CNAME foo being queried, then someserver.somehost.com. being queried, resulting in one extra query.

For every element in the chain you will add, another query will be required.

Another reason this is discouraged is that, by creating chains like these, the chances you will somehow create CNAME loops are increased; these should be detected automatically by current DNS servers, but would still impose a large load on the servers.


Solution 3:

Yes, it's allowed and will work, but it's not considered good practice. The multiple lookups use more resources, and there's a risk of accidentally creating a loop.