Using CNAME to point to another domain to save IP addresses

I have one server which I'm hosting a handful of sites on.

Currently, each site has it's domain hosted by an independent provider and each has an A record pointing to the server's IP address.

But if I want to change the server in the future, I will have to go back an update each IP address in each DNS record.

Is it possible to use a CNAME record on each domain to point to another domain that I control directly?

This is so I can update the IP address in 1 place myself and not have to get all these other DNS providers to update their records separately?


That's exactly the point of a CNAME. A CNAME does not need to point to a DNS in the same zone, it can point to any DNS name registered with any nameserver.

What it means for your clients is an additional DNS lookup on the NS for the other host, but that's a tiny price to pay for the majority of websites on the internet.


Per Farseeker's answer, yes, this is (sort of) what CNAME records are for.

However whilst you can use this to point www.example.net to www.example.com, you can't use it to point example.net on its own (i.e. without the www prefix) to something else.

This is because example.net must also have an SOA record and NS records, and it's not legal in DNS to have a CNAME present at the same part of the tree as any other records (DNSSEC keys excepted).

The "sort of" qualifier above, is because strictly speaking the CNAME record introduces the "left hand side" as an alias for the target of the CNAME record, where that target is actually the "canonical name".

Hence if you see e.g.:

www.example.net IN CNAME www.example.com.

It is not saying that www.example.net should be "redirected" to www.example.com, it's saying that the www.example.net is another name for www.example.com.


Yes it is possible.

That's how I do my experimental web servers that also have dynamic IPs (though seldom changed).