Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the * in a CNAME record take priority over explicit subdomains?

I have a set of subdomains defined on my domain like this:

CNAME sub1.example.com -> sub1.herokuapp.com CNAME sub2.example.com -> sub2.appspot.com CNAME www.example.com -> example.herokuapp.com 

Now I'd like to add CNAME *.example.com -> example.herokuapp.com to catch folks who put in too many WWWs or type in other missing subdomains. But will the * take priority over the explicitly defined subdomains or will the subdomains continue to work as expected?

I'm using Route53 if it makes a difference.

like image 418
Sudhir Jonathan Avatar asked Feb 07 '13 17:02

Sudhir Jonathan


People also ask

Does A record take priority over CNAME?

A CNAME will take precedence over all other DNS records. This means that when a CNAME is present, all other DNS records are ignored. This includes NS records, A records, MX records, etc.

What does a wildcard CNAME do?

A wildcard DNS record is a record that answers DNS requests for any subdomain you haven't already defined. You can create wildcard A records and CNAME records by entering an asterisk (*) in the Host field when creating a DNS record. For example, if you create the wildcard A record *.

Can a CNAME record point to a subdomain?

A Canonical Name or CNAME record is a type of DNS record that maps an alias name to a true or canonical domain name. CNAME records are typically used to map a subdomain such as www or mail to the domain hosting that subdomain's content.


2 Answers

Wildcards will only match records that aren't otherwise defined in the zone.

See RFC 1912, it mentions MX records here but the same applies to CNAMEs:

2.7 Wildcard records  Wildcard MXs are useful mostly for non IP-connected sites.  A common mistake is thinking that a wildcard MX for a zone will apply to all hosts in the zone.  A wildcard MX will apply only to names in the zone which aren't listed in the DNS at all.  e.g.,         podunk.xx.      IN      NS      ns1                        IN      NS      ns2        mary            IN      A       1.2.3.4        *.podunk.xx.    IN      MX      5 sue  Mail for mary.podunk.xx will be sent to itself for delivery.  Only mail for jane.podunk.xx or any hosts you don't see above will be sent to the MX.  For most Internet sites, wildcard MX records are not useful.  You need to put explicit MX records on every host. 
like image 158
Anew Avatar answered Sep 26 '22 06:09

Anew


No it does not, defined subdomains should take priority over a wildcard.

like image 29
Laniax Avatar answered Sep 22 '22 06:09

Laniax