If you’re hosting a website and don’t have access to manage the DNS, or if you manage hundreds of websites or a large multisite and need a way to handle DNS without manually changing records anytime to move to a new server with a new IP, you can use CNAMES to help solve this problem.
This is a particularly useful tool for your toolbox, especially for those using WP Ultimo to run WaaS networks.
If you’re new to managing DNS, you may first want to check out our article on setting up DNS records: Setting DNS Records.
How it Works
CNAME stands for “canonical name” and it’s used to map one domain to another. This is normally used so that only one A record requires updating anytime you make a server change that would affect multiple records such as “www”.
For our use case here in this article, instead of setting an A record for the root domain (e.g. yourdomain.com), and a CNAME for “www”, you would set both of these up as a CNAME and then point them to another domain name – one that you control.
You can then use this domain that you control to point to the IP of the appropriate vCanopy server. Then, in the future, if you need to move this website to another server, you can update the IP address of the domain that you control, and your clients websites will then also automatically point to this new server due to the CNAME.
You won’t ever need to touch their DNS directly, but this way you can control what IP the website is pointing to.
INFO
Unfortunately, not all DNS providers will allow you to set the root domain up via a CNAME record. Cloudflare and DNS Made Easy both allow for this. Others, like GoDaddy for example, only allow the root domain record to set as an A record. If the DNS provider you or your client is using does not allow for CNAMEs to be used on the root domain, this method will not work for you.
An Example
A good way to do this would be to use a subdomain of your primary website. For example, if your clients website was “vCanopy.xyz”, you could set up their CNAMEs as shown in the image below (this screenshot is from Cloudflare, but you can do this with any service that allows you to manage DNS records):
And then for your own website, you can set up an A record for your subdomain and point it to the server where you host vCanopy.xyz.
vCanopy.xyz and www.vCanopy.xyz will then both automatically point to your server.
For a WaaS network this is particurlarly powerful as you could host hundreds of sites on one server, but easily move them all to another and then simply change this one A record.
Once your own A record is set and your clients (or whomever) records are set, you’re all set!
NOTE
Pointing CNAME records towards a domain behind Cloudflare's proxy has worked perfectly fine in our testing.