A CNAME record in DNS (also called a Canonical Name) is an alias to another DNS record.
The CNAME record has to point to a fully qualified hostname, and can not directly point to an IP address (this is what the A-record is ment for).
CNAME‘s can be used to simplify the administration of a website. Imagina you have a site called “nucleus.be”. For this domain, there will be an A-record to map the domain, to its correct IP (18.104.22.168). You will probably have subdomains as well, such as “www.nucleus.be”, “mail.nucleus.be”, “webmail.nucleus.be” and “ftp.nucleus.be”, so your site is accessible on those addresses too.
You can do this by creating a new A-record for each subdomain, and have it point to the correct IP address. But what if you want to move your website to another server at a later point? Then you’d have to change the A-record for all those subdomains. This may not seem like much in our example, but in larger companies there are easily 100+ subdomains to be managed.
So we’ll try to make this more easier for us: you create 1 A-record called “nucleus.be” to point to the IP address (22.214.171.124). Then you create the CNAME record, called “www.nucleus.be” and have it point to “nucleus.be”. This way, the subdomain “www.nucleus.be” is mapped to “nucleus.be”, which in turn refers to the correct IP. If you change server later on, you’ll only have to replace 1 A-record, all matching subdomains will change automatically (because they are mapped to this main A-record).
If you want to have all subdomains point to the same IP address as the main domain, you can also use wildcards. By creating a CNAME record, called “*.nucleus.be” and map it to “nucleus.be”, you state that all subdomains that are not explicitly defined by another A/CNAME record) are to point to the same address as “nucleus.be”.
Every subdomain that was configured seperately (either through an A-record, or a CNAME) will have priority over the wildcard. You can create a subdomain that refers to a certain IP address, and have all other subdomains refer to another IP, through the wildcard.