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?
-
Aside: this still doesn't give you a way to make mysite.com *itself* a CNAME. – reinierpost Mar 03 '17 at 15:01
8 Answers
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).
- 6,057
- 2
- 28
- 40
-
8Actually you can setup a wildcard DNS with GoDaddy. Just set the Host to "**". – Chris Pietschmann Dec 14 '10 at 15:23
-
1
-
2I 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
-
4I've tested it: ** does not work as a wildcard in GoDaddy DNS. I called multiple times to be sure there was no way to do this (even with their Premium DNS) before switching to another provider for this reason. – mltsy Jul 18 '12 at 19:49
-
1Route 53 also offer wildcard CNAMEs, as do many others DNS service providers I think they're pretty essential in many SaaS apps – MemeDeveloper Nov 21 '12 at 14:48
-
3@mltsy: one of our main sites uses wildcard dns in association with GoDaddy. We have for a few years now and we are not using their Premium DNS. Also, it's `*` not `**`. – NotMe Mar 01 '13 at 02:22
-
If I use a *.mydomain.com as a CNAME that points to a root domain like mydomain.com, can I still set up a other.mydomain.com that points to a different server? Or does it not work because of the "*"? – Cameron Apr 07 '15 at 19:49
-
1As of Feb 2019 it seems GoDaddy does now support wildcard CNAMEs. I've added a record with `*` as domain and it works. https://ua.godaddy.com/help/set-up-wildcard-dns-3301 – e1v Feb 25 '19 at 12:26
-
@e1v I do believe that documentation points out you can do it with A and not CNAME records. – Raydot May 03 '19 at 20:15
-
2@DaveKanter oh, you're right. The article statements are only mentioning A records. Nevertheless I've successfully setup a wildcard `*` CNAME record for a client this February. Using GoDaddy dashboard. And I confirm it works as one would expect. – e1v May 07 '19 at 09:07
-
1@e1v - Yes, it will work as a CNAME except for the 'www' host. For some reason you have to add 'www' separately in GD (if it's a CNAME), even if wildcard CNAME points at same host. And yes: the GD docs say "A" records -only- last I checked. – B. Shea Jul 22 '19 at 20:59
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
.
- 1,365
- 3
- 13
- 27
Just to add that Amazon Route 53 supports wildcards in any record type.
So you can safely use Route 53 as your DNS provider.
- 557
- 2
- 13
- 25
As far as I remember you can(ish) sort of do this, but then that CNAME can't be used by any other record type such as NS or MX.
Not quite sure what you're trying to achieve with the "wildcard" thing, so I'll have to give a generic answer :)
To clarify, CNAME aserver.domain means you can't have anothername.aserver.domain
There are exceptions, but I don't know what they are off the top of my head thou and not really sure what you want to do, so I shan't waste time.
-
Thank you for that warning about sharing a `CNAME` record with another type of record for the same domain. I had a similar problem, and my DNS server usually warns me about clashes, but in this case it didn't because the CNAME was for `*.example.com` and the extra record (a `TXT` record) was for a specific subdomain `subdomain1.example.com`. So it didn't catch the clash! Whoops. – Paul d'Aoust Dec 05 '16 at 18:56
We use wildcard dns all the time, and we haven't had any issues. If you point it to an ipaddres, use:
*.mysite.com Host (A) Default xxx.xxx.xxx.xxx
If you want to use an alias, do:
*.mysite.com. IN CNAME mysite.com.
- 71
- 3
-
The first setup worked out well for us when we used with a [wildcard ssl cert](http://www.ssl.com/certificates/wildcard) (ssl.com) where we wanted each user to have https://username.mysite.com – Yogi Feb 11 '13 at 03:42
when you create a CNAME record end the pointed server with a dot, ex: *.mydomain.com. Notice the last dot
- 121
- 1
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.
- 1,103
- 1
- 8
- 9
-
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 07: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
It does work now.
Just use a "*" in the cname section of the zone file editor or DNS manager from Godaddy an point to an IP or DNS name.
In my case I used it with an DNS name pointing to an Microsoft Azure cloudservice and it worked great. This works for bla.domain.ext but also for bla.bla.domain.ext. Might work different for another provider.
- 111
- 3
-
1DNS CNAME records do not point to URLs or IPs, but to a single DNS name which the name with the CNAME entry is equivalent to. – Falcon Momot Aug 31 '13 at 02:22
-