I know it's valid to have a DNS A record that's a wildcard (e.g. *.mysite.com). Is it possible/valid/advised to have a wildcard CNAME record?

link|improve this question
feedback

7 Answers

up vote 14 down vote accepted

It is possible to do this. At one point it was up in the air a bit until 4592 clarified that it should be supported.

Just because it is possible doesn't mean it is supported by all DNS providers. For example, GoDaddy won't let you set up a wildcard in a CNAME record.

In terms of whether it is advisable or not to do this, it depends on your usage. Usually CNAMES are used for convenience when you are pointing to an "outside" domain name that you don't control the DNS on.

For example, let's say you set up a CMS system that allows you to have *.mycms.com as the site name (it uses host headers). You want customers to be able to easily set up *.cms.customer.com, without worrying that you might change your IP address at some point. In that case, you could advise them to set up a wildcard CNAME called *.cms.customer.com to www.mycms.com.

Because wildcard CNAMES aren't supported by all providers (such as GoDaddy), I wouldn't advise using it in a case where you suggested it for various customers (where you don't know their provider's capabilities).

link|improve this answer
2  
Actually you can setup a wildcard DNS with GoDaddy. Just set the Host to "**". – Chris Pietschmann Dec 14 '10 at 15:23
1  
@Chris did you do that with a CNAME? – mxmissile Jun 3 '11 at 4:02
I see that ** is accepted by GoDaddy's DNS manager tool, but does it work as a wildcard? Seems like an undocumented feature. – dunxd Sep 13 '11 at 14:30
feedback

I added the line

*.www        IN CNAME        my_webserver

to my zone file in my bind config and that worked perfectly (ie. whatever.www.domain.com and whatever2.www.domain.com all pointed to my_webserver.

It was also possible to to add exceptions to this by adding the line

exception.www        IN CNAME        another_server

so that exception.www.domain.com pointed to another_server.

link|improve this answer
feedback

One warning about wildcards: Most people don't understand how they work. For example, they think that a subdomain is what comes between teh dots, when it really isn't. Wildcards don't work like people expect, and that leads to interesting, confusing, or exciting results.

link|improve this answer
1  
thanks for the LOL: "interesting, confusing, or exciting results" – tsykoduk Aug 9 '11 at 16:58
feedback

Just to add that Amazon Route 53 supports wildcards in any record type.

So you can safely use Route 53 as your DNS provider.

link|improve this answer
feedback

when you create a CNAME record end the pointed server with a dot, ex: *.mydomain.com. Notice the last dot

link|improve this answer
feedback

Here are the results of my test. I deleted the A records for mysite.com and www.mysite.com and added a CNAME record for *.mysite.com. The test didn't work. mysite.com wouldn't resolve. Just to be clear, I use OpenDNS for my DNS servers. Maybe it works fine with other DNS servers, but I obviously want it to work universally. Based on those results, I'm going to stick with the standard A records.

link|improve this answer
Isn't this expected behaviour? As far as I can see *.mysite.com won't match mysite.com, regardless of RR type. Does that work with A records? – markdrayton Jul 23 '09 at 19:52
No, '' matches one or more labels, so '.example.com' doesn't match 'example.com' – Alnitak Jul 24 '09 at 7:53
I didn't know that, but it makes sense. So it seems that I need at least one A record for the root domain name and then I could use a wildcard CNAME record to cover everything else. That isn't really the solution I wanted, but at least I know. – Ben Mills Jul 25 '09 at 14:36
feedback

Far as I remember you can(ish) sorta do this, but then that CNAME can't be used by any other record NS/MX. Not quite sure what your trying to achieve with the "wildcard" thing, so a generic answer is it is :)

IE, CNAME aserver.doamin means you can't have anohtername.aserver.domain

There are exceptions, don't know what they are off the top of my head thou and not really sure what you want to do, so I shant waste time.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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