So you can check my comments for a little bit of insight on how to troubleshoot your issue. But I suppose a definitive answer to how DNS records work and how to achieve the redirection you are looking for would be more appropriate. RFCs probably are the proper way to site sources, but I like to explain with my own examples. So I will provide screen shots from my Windows 2016 Active Directory server that runs DNS locally on the server as well. Now if you use something like bind on Linux/Windows then the concepts should hold true, but obviously a different approach to configuration.
So your DNS server is going to have a Forward Lookup zone configured for your domain. Mine for this instance is digiecho.xyz as you can see in the screenshot below:
In the lookup zone you can see that I have an assortment of A records that point to IP addresses. These are the most common types of records created in my experience. So you should have one A record where your www.domain.com points to some IP. For my example I'm going to use my A record for VC01.
A CNAME or Canonical Name allows you to alias one name to another. I'm going to create a CNAME record vcenter.digiecho.xyz and point it to my A record VC01 (see screen shot below for record creation example, and info on CNAMEs):
https://support.dnsimple.com/articles/cname-record/
You then can use DNS tools like dig or nslookup to troubleshoot what is going on. Since this is all on my internal network I just used nslookup from another server on my virtual host to show some relevant outputs to help you in your troubleshooting:
As you can see it not only tells me the true canonical domain the alias points to. However it should report back the server that is reporting back the record. So if you have like a master-slave configuration in your DNS environment you will want to make sure the zone transfers have occurred from the master to all the slaves to ensure that they all have the correct. If you are using Linux just man dig for the command parameters. But really those basic DNS checks and troubleshooting should be sufficient to solve a CNAME issue.