Should I use an A record or a CNAME for a wildcard subdomain?

I think question is about to understand A & CNAME records deeply. I have also found this confusing but after reading couple of blogs, I came up with following understanding:

The A and CNAME records are the two common ways to map a host name (name hereafter) to one or more IP address. Before going ahead, it’s important that you really understand the differences between these two records. I’ll keep it simple.

The A record points a name to a specific IP address. For example, if you want the name blog.myweb.example to point to the server 186.30.11.143 you will configure:

blog.myweb.example     A        186.30.11.143

The CNAME record points a name to another name, instead of an IP address. The CNAME source represents an alias for the target name and inherits its entire resolution chain.

Let’s take our blog as example:

blog.myweb.example              CNAME   my.bitbucket.example
my.bitbucket.example            CNAME   github.map.mybitbucket.example
github.map.mybitbucket.example  A       186.30.11.143

We use GitHub Pages and we set blog.myweb.example as a CNAME of my.bitbucket.example, which in turns is itself a CNAME of github.map.mybitbucket.example, which is an A record pointing to 186.30.11.143. This means that blog.myweb.example resolves to 186.30.11.143.

Conclusion:
A record points a name to an IP address. CNAME record can point a name to another CNAME or an A record.

Source:
Differences between A & CNAME records

Leave a Comment