Cname is the canonical name. Say your nick name is Avi and your full name is Md. Mahim Bin Firoj. So when people call Avi then actually Md. Mahim Bin Firoj replies. Here Avi is the alias and cname is Md. Mahim Bin Firoj. Cname records always points a domain or a sub-domain to another domain. It can not point to an ip address. Only A record points domain names to ip address.
When cname helpful?
Say avi.com is your domain and your public ip is 222.333.444.555 for example. There is A record present in dns for avi.com against this public ip 222.333.444.555 and you need to create this record first in your dns server.
Now you create some sub-domain i.e. ftp.avi.com or isms.avi.com or www.avi.com and you want all of your sub-domains should resolve the same public ip 222.333.444.555 and all it is hosted in the same application server then you can create cname record. The benefit is if you ever need to change the public ip, you can change this against the avi.com domain. Everything will work fine.
Your cname record would be like this (theoretically), ftp.avi.com or isms.avi.com or www.avi.com should be pointed to avi.com
Here ftp.avi.com or isms.avi.com or www.avi.com is aliased meaning people will type ftp.avi.com or isms.avi.com or www.avi.com in their browser and the cname avi.com should be resolved. When you type ftp.avi.com or isms.avi.com or www.avi.com in your browser then dns first returns avi.com as cname record. Then dns again queries to avi.com to get the actual public ip of avi.com which is already present in dns as A record. Its a double query that dns has to made but there is not that much of performance degradation has observed. Instead you can also create A record for all of your sub-domains for better/faster dns query. In that case your dns server will be populated with lots of A records.
Another use case:
Say earlier you had a domain called www.something.net
So now you can create a cname record like this. First place a A record for www.something.com against public ip 222.333.444.555 for example.
So now your cname record would be like this (theoretically), www.something.net should be point to www.something.com
The above image illustrates how it is configured.
Note: You may also need to change some redirection settings in your web server so that proper redirection happens.
Thanks. Please Subscribe below.