Creating a subdomain requires adding a DNS record in your zone file. Whether that record is an A record or a CNAME depends on what you're pointing the subdomain at. This guide covers the rules, the examples, and the common pitfalls, so you get the right record type first time.
A subdomain is any hostname that precedes your domain: www.yourdomain.com, shop.yourdomain.com, staging.yourdomain.com. You don't register subdomains separately, you create them by adding a DNS record with that name in your zone. The DNS record is what makes a subdomain resolve.
There's no limit on the number of subdomains you can create. You can have as many as your DNS provider's zone allows, and they can each point to different servers, services, or IPs.
An A record maps a subdomain directly to an IPv4 address. Use this when you're pointing the subdomain at a specific server you control and know the IP.
Example, creating shop.yourdomain.com pointing to a server:
Use an A record for:
mail.yourdomain.com), must use A, never CNAMEA CNAME maps a subdomain to another domain name rather than an IP address. When the resolver looks up a CNAME, it follows the alias to the target and resolves that target's IP. Use CNAME when a third-party service gives you a hostname to point to, rather than an IP.
Example, pointing store.yourdomain.com to a Shopify store:
The advantage of CNAME over A record for third-party services: when the provider changes their server IP, your subdomain automatically follows. You don't need to update your DNS, the CNAME always resolves to whatever IP the target hostname currently points to.
Use CNAME for:
www pointing to your bare domainyourdomain.com without any prefix) must use an A or AAAA record. The DNS spec prohibits CNAME records at a zone apex because the bare domain also needs SOA and NS records, which cannot coexist with a CNAME at the same name. Some DNS providers offer a proprietary workaround ("ALIAS", "ANAME", or "CNAME Flattening") that resolves the CNAME and publishes the result as an A record, but native CNAME is not allowed.
mail.yourdomain.com must use an A record, if it used a CNAME, you couldn't have MX records pointing to it.
shop, not shop.yourdomain.com (some interfaces want the full hostname, check the field label).Changes propagate within minutes when TTL is low, or up to the TTL duration if records were recently cached.
# Check what the subdomain resolves to dig shop.yourdomain.com A +short # For a CNAME, see the full chain dig shop.yourdomain.com CNAME +short # Query an authoritative nameserver directly dig @ns1.hosted-server.net shop.yourdomain.com A +short
Add and edit DNS records for any domain or subdomain from your HostBible control panel. Register your domain with us and manage everything in one place.
Register a Domain