The CNAME ( Canonical Name record) is a DNS record which points one domain name to another. When using a CNAME you are basically telling the Internet that one domain name is simply an alias for another domain name.
All traffic sent to the first domain name will go directly to the second domain name.
This can be very useful when redirecting a subdomain. For example, lets say you own example.com. You want all traffic which is sent to www.example.com to go to example.com. This is easily accomplished by a CNAME record.
Point www.example.com to example.com using a CNAME and you are done.
However, this will NOT work in the opposite direction. You should never use a CNAME with a top level domain name. Doing so will lead to unexpected results.
For example, you should not forward example.com to www.example.com using a CNAME.
A CNAME will take precedence over all other DNS records. This means that when a CNAME is present, all other DNS records are ignored. This includes NS records, A records, MX records, etc.
A top level domain, such as example.com must have an NS record, telling the world where the authoritative name servers for that domain name can be found. But when a CNAME also exist, the CNAME takes precedence over the NS records, so the authoritative name servers are not found. DNS gets broken.
If you have an MX record and a CNAME together for the same URL, then the MX record is ignored. Email might not function as expected.
Basically things break if you use a CNAME with a top level domain. Stick to using CNAME records with subdomains only and you should be OK.
If you want to redirect a top level domain to a subdomain (pointing example.com to www.example.com) you should use a different form of redirection, such as a 301 redirect. A 301 redirect is going to be more search engine friendly than a DNS redirect.
A CNAME record must point to another domain name, not an IP address. use an A record for point a domain name to an IP address.