The A records are, together with the CNAME records, the most used ways to point any hostname to a specific IP address or more. While they share a similar function, there are a few differences between them that are important to know. Let’s take a look at this then.
First off, an A record is used to point a hostname to an IP address or more. Yes, you can point the same hostname to different IP addresses using more A records. If you want to point “mydomain.com” to the IP 126.96.36.199, then this would be your A record:
mydomain.com. 3600 IN A 188.8.131.52
Now let’s see what the CNAME record is about. CNAME records are used to point a hostname to another hostname. What’s different here? Well, in the A record we pointed the hostname to an IP (or more). The CNAME record is an alias of the target hostname and will get the same resolution chain that the target has. Let’s see an example of a CNAME point “mydomain.com” to “domain2.com”:
mydomain.com. 3600 IN CNAME domain2.com.
And now let’s see an example that uses both A records and CNAME records:
myshinydomain.com. 3600 IN CNAME mydomain.com mydomain.com. 3600 IN A 184.108.40.206
What does this mean? First, myshinydomain.com is an alias of mydomain.com, and second mydomain.com is pointing to server 220.127.116.11, so in the end myshinydomain.com will be pointing to 18.104.22.168 too.
And that’s it. Like we said, A records are used to point a hostname to one IP or more, while CNAME records are used to point a hostname to another hostname, or to an A record depending on the resolution chain.