CNAME dns record explanation

Md. Mahim Bin Firoj
3 min readSep 5


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?

image source: PowerCert

Say is your domain and your public ip is 222.333.444.555 for example. There is A record present in dns for 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. or or 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 domain. Everything will work fine.

Your cname record would be like this (theoretically), or or should be pointed to

Here or or is aliased meaning people will type or or in their browser and the cname should be resolved. When you type or or in your browser then dns first returns as cname record. Then dns again queries to to get the actual public ip of 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

Now you purchased a new domain called Now the fact is all of your previous users first hit and they get some error.

So now you can create a cname record like this. First place a A record for against public ip 222.333.444.555 for example.

So now your cname record would be like this (theoretically), should be point to is aliased and the cname record is

image source: Tony Teaches Tech

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.





Md. Mahim Bin Firoj