I have many sites (each one with its own domain) all on the same cPanel hosted server (let's say server IP is and server main domain is myserver.com)

All these domains use third party DNS (not the cPanel hosted ones), I set up the DNS of each one of these domain to point to server IP. Example of how each domain DNS is currently set:

domainx.com -> A ->
domainx.com -> MX -> mail.domainx.com
mail.domainx.com -> A ->
www.domainx.com -> CNAME -> domainx.com
ftp.domainx.com -> CNAME -> domainx.com

This situation obliges me to repeat hundreds times the server IP one time for each domain. In the event that server IP changes I will have to go through each domain DNS to update records with new IP.

So I thought why not use CNAME to avoid rewriting server IP everywhere?! I could set each domain DNS like the following:

domainx.com -> CNAME -> myserver.com
domainx.com -> MX -> mail.myserver.com
mail.domainx.com -> CNAME -> myserver.com
www.domainx.com -> CNAME -> myserver.com
ftp.domainx.com -> CNAME -> myserver.com

But I read that domainx.com -> CNAME -> myserver.com is evil, see this and this.

But what alternatives do I have to avoid rewriting server IP everywhere?


But I read that domainx.com -> CNAME -> myserver.com is evil

CNAMEs are not evil. However using CNAMES for a second level domain will break DNS for those domains. You cannot add MX, TXT or just about any other records at the same level as the CNAME record. From rfc1912:

A CNAME record is not allowed to coexist with any other data. In
other words, if suzy.podunk.xx is an alias for sue.podunk.xx, you
can't also have an MX record for suzy.podunk.edu, or an A record, or
even a TXT record. Especially do not try to combine CNAMEs and NS

Technically this might work, but mixing CNAMES with other records may confuse other DNS servers, which is going to cause to cause strange failures and will be an administrative headache.


Although CNAME for domains is evil, there exists a little known DNAME which will do pretty much exactly what you want (and it intended for just that). If will also allow to override certain entries in subdomains (e.g. spf text records, etc..., if you need to) - see this question and my answer for an example.


Why not use a single zone file in BIND?

You make a zone file called virtual_hosts, and place the A records, MX records, etc in there. Then in the named.conf file you point each "simple" domain to the same zone file.

zone "domainx.com" IN {   
    type master;   
    file "virtual_hosts";   
    allow-update { none; }; 

zone "domainy.com" IN {   
    type master;   
    file "virtual_hosts";   
    allow-update { none; }; 

zone "domainz.com" IN {   
    type master;   
    file "virtual_hosts";   
    allow-update { none; }; 
  • Of course, in the third party DNS, just set your DNS servers as the authoritative servers. – NickW Feb 22 '13 at 14:20
  • But is'n this the same of pointing all my domains to my cPanel webhoster's nameservers?! Then I would obviously not need to setup each DNS anymore. But I use third party DNS/nameservers, I don't want to use the webhoster's ones. Sorry maybe it was not clear in my question, I made it more clear now in bold. – Marco Demaio Feb 23 '13 at 14:12
  • Ah.. if I were you, I'd run my own DNS server, much more control, much less work after the initial setup. – NickW Feb 25 '13 at 9:22
  • I would use webhoster nameserver and cPanel to set up my DNS, but in my experience even good webhoster servers might go down once in a while for 48 hours. I noticed that reliable registrar DNS systems are almost always up so I trust them more. What server would you suggest for DNS? – Marco Demaio Mar 1 '13 at 13:34
  • That's due to redundancy, but yeah, if it's your primary responsibility (business wise) you're going to be as stable as possible. – NickW Mar 1 '13 at 13:38

If you have a lot of zones and/or records, you might be better off using APIs to implement them rather than handling them all manually through web interfaces.

Most reputable DNS providers have APIs available. (Example, example, Wiki page.)


use wildcard (*) for records pointing the same IP

Such that test.com is your domain:

$ORIGIN test.com.
*           A

In that case every sub domain will have the A record including www

  • This doesn't address the main issue, which is that he has lots of different domain names that need pointing to the same server. Also the above wildcard doesn't cover the A record for the root zone name which is a big part of the problem (seeing as it can't be a CNAME) – USD Matt Feb 23 '13 at 15:20
  • -1 using * is evil, any subdomain like suckthis.test.com would resolve to my site. – Marco Demaio Mar 1 '13 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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