Default CNAME when DNS quering

cname-recorddomain-name-systemsubdomain

I have a domain, with a number of CNAME records to

www.mydomain.com
mail.mydomain.com
ftp.mydomain.com

Now, what I would like to achieve is that if any other subdomain is queried or the domain itself is queried, I would like to have www.mydomain.com returned such that if

mydomain.com or inexistent.mydomain.com are queried, www.mydomain.com is returned by default.

I am not sure how this is possible if it is? Any help is appreciated.

John

Best Answer

for inexistent.mydomain.com just add

*.mydomain.com. CNAME www.mydomain.com.

But you can't CNAME mydomain.com as it's root of your zone. See here: https://stackoverflow.com/questions/655235/is-root-domain-cname-to-other-domain-allowed-by-dns-rfc

But you can create A record for mydomain.com, and have *.mydomain.com. CNAME mydomain.com.. In this case everything that ends with .mydomain.com would resolve to same ip.