2

Is there a way to redirect an entire domain to another domain through one CNAME record?

For example [anyhost].domain1.com pointing to [anyhost].domain2.com where no matter what host name I enter in domain1.com it will point to the actual ip address of the SAME host name in domain2.com. If I ping www.domain1.com it will resolve to www.domain2.com's ip address. Or if I ping mail.domain1.com it will resolve to mail.domain2.com's ip address, and so on. I know I can enter a CNAME record for each host in domain1.com but that is tedious. Some of the other questions asked in this area shows answers where a specific ip address is used for a default for the domain and that is not what I am looking for as an answer.

Incidentally, I tried using CNAME *.domain1.com *.domain2.com and it didn't work.

4
  • Even if wildcard DNS worked this way (it does not expand past a label, i.e. blah.sub.example.com. is not matched by *.example.com.), you'd still run up against the inability to CNAME the apex record.
    – Andrew B
    Aug 5, 2014 at 18:37
  • 2
    @AndrewB It actually does expand like that (*.example.com. will match blah.sub.example.com. provided that neither sub.example.com. nor blah.sub.example.com. exist) Aug 5, 2014 at 18:39
  • @Håkan Point taken, I stand corrected.
    – Andrew B
    Aug 5, 2014 at 18:47
  • If you control both zones, just use the same zonefile for both on the master.
    – MadHatter
    Aug 6, 2014 at 16:49

2 Answers 2

3

The problem with your attempted *.example.com. CNAME *.example.net. is the value (the canonical name). A CNAME record specifies exactly one name as the canonical name and putting a wildcard there doesn't really mean anything.

There is a somewhat obscure record type that does match the kind of behavior that you describe: the DNAME record type.

If you have a record example.com. DNAME example.net. that means that the authoritative server will, as part of its record lookup process, synthesize CNAME records as necessary to map names under example.com. to the corresponding name under example.net. (eg a.b.example.com. CNAME a.b.example.net.).

And as the actual DNAME record isn't presented to the client (unless the query is specifically for the DNAME record type), the relative obscurity of the record type should only be a factor in that your authoritative nameservers must support it.

The question does not mention dealing with the zone apex, but if that is your goal then this solution will not handle that. (CNAME cannot exist at the zone apex.)

8
  • I took "entire domain" in the summary to include the apex as it was not worded as "all subdomains". Kudos for being aware of DNAME all the same.
    – Andrew B
    Aug 5, 2014 at 19:12
  • @AndrewB Yeah, you may be right. The rest of the question seems to focus on *.example.com., though. Either way, I hope it may be useful because I believe this is as close as it will get to what the question seeks. Aug 5, 2014 at 19:28
  • I don't think Windows Server 2012 DNS supports DNAME records and CNAME records are host related, not domain related. Looks like I'm stuck with created records for each host.
    – Corey
    Aug 6, 2014 at 15:38
  • @Corey I don't have msdns readily available to look at but DNAME is listed here technet.microsoft.com/en-us/library/jj649925.aspx Aug 6, 2014 at 16:28
  • I looked down deeper into the DNS interface and DNAME records are supported. They are classified as "Other" records. I'll look into using them a little later. I may be on to something.
    – Corey
    Aug 6, 2014 at 16:50
1

I'd be copying one of the forward zone records to the other zone, making some type of global edit, and then using both.

I can see that you could do this with include files to maximize the amount of sharing while minimizing problems.

Not the answer you're looking for? Browse other questions tagged .