C.3 DNS records
There are many types of DNS records, and you may see a full list on Wikipedia. The most commonly used types may be A, CNAME, and MX records. Figure C.1 shows a subset of DNS records of my domain
yihui.name on Cloudflare, which may give you an idea of what DNS records look like. You may query DNS records using command-line tools such as
dig or an app provided by Google: https://toolbox.googleapps.com/apps/dig/.
An apex domain can have any number of subdomains. You can set DNS records for the apex domain and any subdomains. You can see from Figure C.1 that I have several subdomains, e.g.,
As we have mentioned, an A record points a domain or subdomain to an IP address of the host server. I did not use any A records for my domains since all services I use, such as Updog, GitHub Pages, and Netlify, support CNAME records well. A CNAME record is an alias, pointing one domain to another domain. The advantage of using CNAME over A is that you do not have to tie a domain to a fixed IP address. For example, the CNAME record for
twitter-yihui.netlify.com. The latter domain is provided by Netlify, and I do not need to know where they actually host the website. They are free to move the host of
twitter-yihui.netlify.com, and I will not need to update my DNS record. Every time someone visits the website
t.yihui.name, the web browser will route the traffic to the domain set in the CNAME record. Note that this is different from redirection, i.e., the URL
t.yihui.name will not be explicitly redirected to
twitter-yihui.netlify.com (you still see the former in the address bar of your browser).
Normally, you can set any DNS records for the apex domain except CNAME, but I set a CNAME record for my apex domain
yihui.name, and that is because Cloudflare supports CNAME flattening. For more information on this topic, you may read the post “To WWW or not WWW,” by Netlify. Personally, I prefer not using the subdomain
www.yihui.name to keep my URLs short, so I set a CNAME record for both the apex domain
yihui.name and the
www subdomain, and Netlify will automatically redirect the
www subdomain to the apex domain. That said, if you are a beginner, it may be a little easier to configure and use the
www subdomain, as suggested by Netlify. Note
www is a conventional subdomain that sounds like an apex domain, but really is not; you can follow this convention or not as you wish.
For email services, I was an early enough “netizen”, and when I registered my domain name, Google was still offering free email services to custom domain owners. That is how I can have a custom mailbox
firstname.lastname@example.org. Now you will have to pay for G Suite. In Figure C.1 you can see I have set some MX (stands for “mail exchange”) records that point to some Google mail servers. Of course, Google is not the only possible choice when it comes to custom mailboxes. Migadu claims to be the “most affordable email hosting.” You may try its free plan and see if you like it. Unless you are going to use your custom mailbox extensively and for professional purposes, the free plan may suffice. In fact, you may create an alias address on Migadu to forward emails to your other email accounts (such as Gmail) if you do not care about an actual custom mailbox. Migadu has provided detailed instructions on how to set the MX records for your domain.