How to setup sub domain in Cloudflare

Hi,

I have added a A record point to my server IP and added a Cname record for “www”

But, may I know how can I setup sub-domain ? should I use A record, AAA or CNAME ?
How to config it ?

Thanks everyone.

The sort answer is yes, you should use one of those. :wink:

Which one is best suited to your needs is something you need to determine.

You can use a CNAME if you need to point to the origin IP of another existing host that already has an A or AAAA record. While you technically can chain CNAMEs it is a bad practice and should be avoided whenever possible. One advantage to a CNAME is that if the IP for the related changes, you only have to update the address in the record for the canonical name. (The canonical name is the name listed in the target box in the Cloudflare DNS interface. The name of the label holding the CNAME resource is known as an alias.) One disadvantage of CNAME records is that no other records may exist in the same namespace. That means no TXT records, MX records, etc, can have the same name as a CNAME.

You use an A record when your origin host is listening on IPv4 and a AAAA record when the origin host is listening on IPv6. When creating either an A or AAAA record in your Cloudflare zone, both an A and a AAAA record will be published pointing to Cloudflare proxy IPs. This allows your visitors to be on either IPv4 or IPv6 even if your host is only on one or the other.

One other thing to keep in mind with subdomains on Cloudflare is that if you need to use any non HTTP protocols, such as email, you cannot set the record to :orange: proxied. They will need to be :grey: DNS Only.

Hi

okay. Thanks and understand now.
So if I use CNAME for the sub-domain, the benefit is I only need to change the A record if the IP changed in the future.
Also, I can’t use proxied for the subdomain (CNAME) , can only use DNS only, am I correct ?

Thanks!

You can absolutely proxy a CNAME. You can even proxy a wildcard CNAME, recent change, used to require a paid plan to proxy a wildcard entry. Keep in mind that when you proxy a CNAME, the public won’t be able to tell that it’s a CNAME, if you run an nslookup on it it’ll return A / AAAA records pointing to Cloudflare IPs, just like with a proxied A or AAAA record.

So you can possibly get away with just creating a wildcard (*) CNAME to cover every possible subdomain you might ever

It depends on how you will be using the hostname in question. If it will be only for HTTP and HTTPS, then you can leave it :orange: proxied. It only needs to be :grey: if you will be using other protocols, like email.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.