Domains and DNS

A record vs CNAME: which DNS record should you use?

Use an A record to point a name, including your root domain, at your server's IP address. Use a CNAME to make a subdomain such as www follow another hostname. A CNAME cannot sit on the root domain.

Updated 3 min readApplies to: All plans

When this matters

If your domain uses your hosting's nameservers, cPanel and Plesk normally create the basic records for each domain you add. You need this article when your DNS stays somewhere else (at your registrar or a DNS provider), or when you add a subdomain, connect an outside service, or move a site. If DNS itself is new to you, start with what DNS is.

The difference in one table

A record CNAME record
Points to An IPv4 address, such as 203.0.113.10 Another hostname, such as example.in.
Use on root domain (example.in) Yes No
Can share the name with other records (MX, TXT) Yes No, a CNAME must be alone at its name
When the server IP changes Update every A record Update only the target's A record
Typical use Root domain, mail server host, any name pointing at your hosting IP www, subdomains that follow a third party service

An AAAA record is the same as an A record but for an IPv6 address.

Example records for example.in

The IP addresses below come from ranges reserved for documentation (RFC 5737). Use the real IP from your welcome email.

; Root domain and www on your hosting server
example.in.          3600  IN  A      203.0.113.10
www.example.in.      3600  IN  CNAME  example.in.

; A subdomain on the same server
blog.example.in.     3600  IN  A      203.0.113.10

; A subdomain handed to an outside service (shop, help desk, etc.)
shop.example.in.     3600  IN  CNAME  stores.provider.example.

; Mail: MX must point at a name with an A record, never a CNAME
example.in.          3600  IN  MX     10 mail.example.in.
mail.example.in.     3600  IN  A      203.0.113.10

Why the root domain cannot be a CNAME

RFC 1034 says that if a CNAME exists at a name, no other data should exist there, and RFC 1912 repeats that a CNAME "is not allowed to coexist with any other data". The root domain (also called the apex, example.in itself) must always hold SOA and NS records, and usually MX and TXT records too. A CNAME there would break those records, so most DNS editors refuse to save it.

If a service asks you to "CNAME your root domain", you have three options:

  1. Use an A record with the IP addresses the service publishes for root domains.
  2. Use your DNS provider's ALIAS, ANAME or "CNAME flattening" feature if it has one. This is provider specific and not part of the DNS standard.
  3. Redirect the root domain to www and put the CNAME on www.

How to add or change a record

These are generic steps. Menus vary by version and by what your DNS host enables.

  1. Open the DNS editor where your domain's nameservers point. On ODHOST cPanel hosting this is usually Domains > Zone Editor > Manage. At a registrar, look for "DNS" or "Manage DNS".
  2. Check for an existing record with the same name. Delete or edit it rather than adding a duplicate, and remember a CNAME cannot share its name with an A record.
  3. Add the record: enter the name (www or www.example.in. depending on the form), the TTL, the type, and the value.
  4. Save the record.

Not sure which DNS editor is in charge? Run dig NS example.in +short and compare the answer with the nameserver steps.

How to confirm it worked

dig example.in A +short
dig www.example.in +short

The first command should return your server IP. The second should return example.in. followed by the same IP. If you see the old value, the cache has not expired yet; see DNS propagation.

If it still fails

Open a support ticket and include:

  • The domain and the exact records you added, copied as text
  • Where DNS is hosted (ODHOST, your registrar or another provider)
  • The output of the two dig commands above
  • The error the browser or the outside service shows

Frequently asked questions

Can I use a CNAME for my root domain?

Not in standard DNS. The root domain must carry SOA and NS records, and a CNAME cannot coexist with any other record at the same name. Some DNS providers offer ALIAS, ANAME or CNAME flattening as a provider specific workaround.

Should www be an A record or a CNAME?

Either works. A CNAME from www to the root domain means you only update one IP address if you move servers; an A record saves one extra lookup.

Can an MX record point to a CNAME?

No. RFC 2181 says MX targets must be names with their own A or AAAA records, not aliases. Point MX records at a hostname that has an A record.

Where do I get my server's IP address?

Your ODHOST welcome email lists the server details for your account. If it is not there, ask support through a ticket.

Sources and further reading

Contact us