Abstract server and code screen symbolizing DNS CNAME aliases pointing hostnames to other domains

CNAME Records: When and How to Use DNS Aliases Instead of A Records

Sometimes you do not want to point a domain or subdomain directly to an IP address. Instead, you want it to behave like a nickname for another domain. That is exactly what a CNAME record does. It lets you create an alias such as www.example.com that simply follows whatever you set for example.com or another host.

You can think of a CNAME as a “forwarding label” in DNS: it says “do not look for records here, look over there instead.” Used correctly, it saves time, reduces mistakes, and makes your DNS setup easier to manage.

What Is a CNAME Record in Simple Terms?

A CNAME (Canonical Name) record is a DNS record that points one hostname to another hostname, not to an IP address. When a DNS resolver sees a CNAME, it understands that this name is just an alias.

For example:

www.example.com.     CNAME    example.com.

Here, www.example.com is just a nickname for example.com. When someone visits www.example.com, DNS looks up example.com to find the actual A or AAAA records and uses those IPs.

Key idea: a CNAME never holds the IP address itself. It always points to another name, and that name holds the IP data.

CNAME vs A Record: What’s the Difference?

It is easy to confuse CNAME and A records, because both are used to make domains work. The difference is what they point to:

  • A record → points a hostname to an IPv4 address (like 198.51.100.10).
  • AAAA record → points a hostname to an IPv6 address.
  • CNAME record → points a hostname to another hostname.

If you point blog.example.com with an A record, you hard-code an IP. If you point it with a CNAME, you just say “use the same details as this other domain.”

Example difference:

; Using an A record
blog.example.com.    A       198.51.100.20

; Using a CNAME
blog.example.com.    CNAME   hosting.example.net.

With the A record, if the server IP changes, you must update the A record. With the CNAME, if hosting.example.net already has the right A/AAAA records and they change, your blog automatically follows.

How CNAME Records Work Behind the Scenes

Let’s slow down the process that happens when someone visits a hostname that uses a CNAME.

  1. The user types www.myshop.com into their browser.
  2. The browser’s DNS resolver asks for records for www.myshop.com.
  3. The nameserver finds a CNAME:
    www.myshop.com.    CNAME   myshop.com.
  4. The resolver understands that www.myshop.com is an alias for myshop.com, so it then asks for records for myshop.com.
  5. It finds the A and AAAA records for myshop.com:
    myshop.com.    A      198.51.100.40
    myshop.com.    AAAA   2001:db8:1234::40
  6. The resolver returns those IP addresses to the browser, which connects to the server and loads the website.

The visitor never sees the extra step, but this small chain of lookups is what makes CNAME aliases work.

Typical Use Cases for CNAME Records

CNAME records are very common in real-world DNS setups. Here are some situations where they are especially useful.

1. Making “www” Follow the Root Domain

One of the most classic uses is to make www.example.com follow example.com.

example.com.        A       198.51.100.10
www.example.com.    CNAME   example.com.

Now you only manage the IP on example.com. Both example.com and www.example.com always point to the same server without extra work.

2. Pointing a Subdomain to a Third-Party Service

Many third-party services (like website builders, marketing tools, or SaaS apps) ask you to create a CNAME that points your subdomain to theirs.

For example, a newsletter service might tell you to add:

newsletter.example.com.    CNAME    yourbrand.newsservice.com.

Now when someone goes to newsletter.example.com, DNS sends them to the servers of the newsletter platform, but the domain in the browser still shows your brand.

3. Simple Internal Aliases

Inside larger setups, CNAMEs are used to create human-friendly names for technical hosts. For example:

db.example.com.        CNAME    db01.internal.example.com.
files.example.com.     CNAME    storage-frontend.example.net.

Engineers can move the underlying servers around (changing A/AAAA records on those technical names) without changing every client that uses db.example.com or files.example.com.

Important Limitations of CNAME Records

CNAMEs are powerful, but they come with a few strict rules that often surprise people the first time.

You Usually Cannot Use a CNAME at the Root

In traditional DNS, the root of the domain (often written as @) cannot be a CNAME if there are other records like NS or SOA, which almost every domain needs. That means you typically cannot do this:

@    CNAME   some-other-domain.com.    ; usually invalid

Instead, you must use A/AAAA records at the root, or your DNS provider might offer a special feature (sometimes called ALIAS or ANAME) that behaves like a CNAME but is implemented differently under the hood.

A Host with a CNAME Cannot Have Other Record Types

If a name has a CNAME record, it should not have other types of records at the same level (like A, MX, or TXT). For example, this is considered bad or invalid:

app.example.com.    CNAME   app.hosting.com.
app.example.com.    A       198.51.100.99    ; conflicting

DNS resolvers expect a CNAME name to be a pure alias. Mixing record types on the same name can cause unpredictable behavior.

CNAME and MX Records Do Not Mix on the Same Name

For email, the names used in MX records should not be CNAMEs. Instead, they should have direct A/AAAA records. For example, this is the recommended pattern:

example.com.      MX      10 mail.example.com.
mail.example.com. A       198.51.100.60

Making mail.example.com a CNAME can cause problems with some mail servers or fail certain checks.

Setting Up a CNAME Record in Practice

Most DNS control panels follow a similar structure when you create a CNAME. Here is a common pattern for adding an alias.

  1. Log in to the DNS control panel for your domain.
  2. Go to the DNS records or “Zone Editor” section.
  3. Click “Add record” and choose type CNAME.
  4. Fill in the fields:
    • Name / Host: the subdomain you want to serve as an alias (for example, www or blog).
    • Target / Points to / Value: the hostname you are pointing to (for example, example.com or yourbrand.service.com).
    • TTL: how long other DNS servers should cache this alias.
  5. Save the record and wait for DNS caches to update.

If the control panel asks whether the target is “a domain” or “an IP”, always choose domain for CNAMEs, because they never point directly to addresses.

Combining CNAME with A and AAAA Records

In a tidy DNS setup, CNAMEs sit at the edges while A/AAAA records live at the “core.” You might have something like this:

@              A       198.51.100.10
@              AAAA    2001:db8:1234::10
www            CNAME   @
blog           CNAME   blog.hostingplatform.com.
api            A       198.51.100.20
status         CNAME   status.statuspage.io.

Here:

  • The root domain and API point directly to IP addresses.
  • www follows the root domain via a CNAME.
  • blog and status are aliases to external services.

This pattern keeps your main IP management in a small set of A/AAAA records and lets CNAMEs handle the “nice names” and external integrations.

Common Mistakes with CNAME Records

When people first use CNAMEs, a few problems show up again and again.

  • Putting a CNAME at the root – many DNS providers block this or cause odd behavior. Use A/AAAA or a special ALIAS/ANAME feature instead.
  • Mixing CNAME with other records on the same host – adding an A, MX, or TXT on a name that already has a CNAME can break DNS expectations.
  • Pointing a CNAME to a URL with “http://” – CNAME targets must be hostnames only, without protocol or path (so service.example.com, not https://service.example.com/login).
  • Forgetting the trailing dot in raw zone files – in advanced editors, example.com. and example.com can behave slightly differently; control panels usually handle this for you, but zone files do not.

If something does not work as expected, checking for these mistakes is a quick way to find the problem.

Simple Scenario: Brand Subdomain for a SaaS Tool

Imagine you use a helpdesk platform at yourbrand.supportservice.com, but you want customers to see help.yourbrand.com in the browser.

  1. In your DNS zone, you create:
    help.yourbrand.com.    CNAME    yourbrand.supportservice.com.
  2. In the helpdesk platform settings, you tell it to expect connections on help.yourbrand.com.
  3. When someone visits help.yourbrand.com, DNS automatically sends them to the helpdesk platform’s servers.

Your visitors see a clean, on-brand URL, while you rely on the provider’s infrastructure behind the scenes.

FAQ

Can I use a CNAME for my main domain (root)?

In traditional DNS, the root of the domain cannot be a CNAME if there are other required records like NS and SOA. Some DNS providers offer special record types (ALIAS, ANAME) that behave like a CNAME at the root, but technically they implement it differently so the zone remains valid.

Does a CNAME affect SEO or how my site appears?

Search engines see the final content and URLs, not the DNS trick behind them. Using a CNAME for www or a subdomain does not hurt SEO by itself. What matters more is whether users and search engines can reach your content reliably and consistently.

Can a CNAME point to a domain in another zone?

Yes. A CNAME can point to any valid hostname, even if it is under a completely different domain or managed by a third party. This is exactly how many SaaS and cloud services work with custom domains.

Is a CNAME the same as a redirect?

No. A CNAME only affects DNS resolution, not browser behavior. It tells DNS to get records from another name, but it does not instruct the browser to change the URL. For true redirects (like sending visitors from oldsite.com to newsite.com), you use HTTP redirects on the web server or a redirect service.

How can I check if my CNAME works?

You can use online DNS checkers or tools like dig with dig CNAME hostname. If the tool shows a CNAME pointing to the correct target and the target has valid A/AAAA records, your alias is probably configured correctly.

CNAME records are a small feature in DNS, but they give you a lot of flexibility. Once you see them as clean aliases that point names to other names, it becomes much easier to design tidy, maintainable DNS zones for your websites and services.

Related Articles