what is cname in dns
A CNAME in DNS is a special record that makes one hostname an alias of another hostname, instead of pointing directly to an IP address.
Quick Scoop: What is a CNAME in DNS?
- CNAME stands for “Canonical Name” record.
- It tells DNS: “this name is just another label for that other domain name.”
- Unlike an A record, a CNAME never points to an IP address, only to another domain/hostname.
Example:
blog.example.com CNAME example.com
When someone visitsblog.example.com, DNS first resolvesexample.comand returns its IP via the A/AAAA record.
How a CNAME Works (In Plain English)
- User types
blog.example.comin the browser.
- DNS looks up
blog.example.comand finds a CNAME pointing toexample.com.
- DNS then does a second lookup for
example.comto get its A/AAAA record and IP.
- The browser connects to that IP, but the request still contains
blog.example.comas the Host header, so the server can serve blog content if configured that way.
Think of a CNAME like a “See also” card in a library catalog that sends you to the main card that has the real shelf location.
Why Use a CNAME Record?
Common use cases:
- Managing many subdomains that all go to the same service (e.g.,
www,blog,shop). - Pointing branded subdomains to third‑party services (e.g.,
help.example.com→ your helpdesk provider).
- Domain ownership verification (e.g., Google or other SaaS tools giving you a special CNAME target).
- Keeping DNS easier to maintain: change the IP in one place (the canonical domain’s A record) and all CNAME aliases automatically follow.
Key Rules and Restrictions
These are important “gotchas” with CNAMEs:
- A CNAME must point to a domain name, not an IP address.
- A name that has a CNAME cannot have other record types at the same label (no MX, TXT, A, etc., on the same exact name).
- Long CNAME “chains” (A → B → C → …) are technically allowed but discouraged because every extra hop adds lookup time.
- Many providers do not allow CNAME at the root (apex) of the domain (e.g.,
example.com), only on subdomains likewww.example.com.
Simple HTML-Style Table of CNAME Facts
| Aspect | Details |
|---|---|
| Full name | Canonical Name (CNAME) DNS record | [3][5][1]
| Points to | Another domain/hostname, not an IP address | [9][5][1]
| Main purpose | Create an alias so multiple names resolve to the same underlying host | [3][9][1]
| Typical use | Subdomains (e.g., www, blog, shop) and third‑party SaaS integrations | [2][7][5][3]
| Can it coexist with other records on the same name? | No, you cannot have A, MX, TXT, etc. on a name that has a CNAME | [5][8][1]
| Performance note | Each CNAME adds at least one extra DNS lookup; long chains hurt performance | [8][1][5]
Mini “Story-Style” Example
Imagine you host your main site at example.com and your infrastructure team
sometimes changes its IP.
- You set
www.example.comandblog.example.comas CNAMEs toexample.com.
- Later, your hosting provider gives you a new IP for
example.com; you only update the A record forexample.com.
- Instantly,
www.example.comandblog.example.comboth follow that change automatically, with no extra edits.
This is the practical power of CNAME: fewer moving parts to manage, less chance of missing an update. TL;DR: A CNAME record in DNS is an alias that maps one hostname to another hostname (never directly to an IP), mainly used to simplify DNS management and keep multiple domains or subdomains pointing to the same underlying service.
Information gathered from public forums or data available on the internet and portrayed here.