What is a CNAME (canonical name) record?
Explore IBM NS1 Connect Managed DNS
Illustration demonstrating web traffic routing

Published: 21 February 2024
Contributors: Tasmiha Khan

What is a CNAME (canonical name) record?

A CNAME record, or canonical name record, serves as an alias within the Domain Name System (DNS), redirecting one domain name to another.

It allows multiple domain names to resolve to the same IP address and simplifies the process of managing various services or subdomains by pointing them to a single destination domain. Notably, all CNAME records must direct to a domain name rather than an IP address.

The ”www” subdomain is a common CNAME example. It is provided as an alias to the root domain name, and users accessing "www.example.com" are referred to the root domain (or DNS zone apex) “example.com”.

The canonical name record might sound complex, but it's a relatively simple, helpful tool in the world of the internet and DNS. Imagine DNS as a huge naming database, like a phonebook, responsible for connecting familiar website names like "www.example.com" to the actual internet protocol (IP) addresses, which is a unique set of numbers. CNAME records help organizations manage domains, distribute and balance traffic more efficiently, and ultimately deliver a faster, more seamless user experience.

Request a live NS1 Connect demo

Improve application performance and add resilience with managed authoritative DNS and advanced traffic steering solutions.

Related content

Subscribe to the IBM newsletter

What is a DNS CNAME record used for?

CNAME records serve as pointers or aliases, redirecting one domain name to another. They are crucial for simplifying web hosting setups, particularly when managing multiple subdomains or frequent redirect changes.

The significance of a CNAME record lies in its ability to offer flexibility and ease in managing domain redirection and service allocation. It allows swift changes to a domain's endpoint without disrupting associated network services or altering other records. 

Common use cases include:

  • Pointing a hostname for network services such as email, FTP, or CDNs (content delivery networks) to the root domain name (the “true name”)

  • Pointing subdomains built for different customers on a service provider’s domain (company.hostname.com) to the root domain (company.com)

  • Redirecting traffic to an optimal CDN based on user location, DNS server or CDN availability, or other factors

  • Registering a domain name in multiple countries and pointing websites that are built for different geos/countries to the main domain

  • Pointing websites that are owned by the same company to a primary domain
DNS resolution process for CNAME records

The following resolution process example demonstrates how CNAME records work:

1.    A DNS client requests an address (initiates a DNS query), and a DNS request is created. For this example, we will use www.example.com as the requested address.

2.    A DNS resolver receives the request and locates the authoritative name server that holds the DNS zone file with DNS records for the “example.com” domain.

3.    The DNS request is resolved and the CNAME record is returned to the client.

4.    The client recognizes that www.example.com is an alias for the address “example.com.” The client starts a new query for “example.com.”

5.    A DNS request for “example.com” is created and the resolver locates and returns the A record for “example.com.” The A record contains the IP address.

6.    With this IP address, the DNS client connects to “example.com.”

Restrictions on CNAME records

Certain restrictions apply to CNAME records and how they can be used, including:

  • A CNAME cannot be placed at the root domain level. The root domain is the DNS start of authority (SOA), which must point to an IP address.

  • A CNAME record points to another domain name. CNAME records never point to an IP address.

  • A hostname defined in a CNAME record cannot have any other resource records of other types, like mail exchange (MX) records, TXT records, or A records. There are exceptions for DNSSEC records, like RRSIG and NSEC.

  • A CNAME record can point to another CNAME record, but this is inefficient and not considered good practice.

  • MX records and name server records (NS records) must never point to a CNAME alias.
What is the difference between CNAME records, alias records and redirects?

Alias records serve a purpose similar to CNAME records by redirecting one domain name to another. Understanding the nuances between CNAME records, alias records, and redirects, and their relationships within the DNS landscape, is fundamental for efficient domain management.

CNAME records act as aliases, directing one domain name to another. They are primarily used for subdomains and cannot coexist with other records on the same hostname. 

Alias records, similar in function to CNAME records, offer a workaround by permitting the simultaneous use of other record types. Redirects, however, function differently by guiding users and search engines to different URLs and are typically implemented at the web server level. 

An A record (address record) directly maps a domain name to an IPv4 address. AAAA records map a domain name to an IPv6 address. Unlike CNAME records, A records don't provide an alias but rather a direct translation of a domain name to an IP address.

In the broader context of DNS, CNAME records, alongside other records like MX, A, TXT, and NS, play specific roles in directing domain names, routing traffic, specifying mail servers, mapping to IP addresses, storing textual data, and indicating authoritative name servers.

Related solutions
IBM NS1 Connect Managed DNS

IBM® NS1 Connect Managed DNS service delivers resilient, fast, authoritative DNS connections to prevent network outages and keep your business online, all the time.

Explore IBM NS1 Connect Managed DNS Request a live demo

DDoS attack prevention with IBM NS1 Connect

IBM NS1 Connect protects your business from DDoS attacks on DNS through strong platform-level resilience and an option to shield your bill from unexpected DNS traffic spikes.

Explore DDoS attack prevention with IBM NS1 Connect

IBM NS1 Connect

IBM NS1 Connect provides fast, secure connections to users anywhere in the world with premium DNS and advanced, customizable traffic steering. Always-on, API-first architecture enables your IT teams to more efficiently monitor networks, deploy changes and conduct routine maintenance.

Explore IBM NS1 Connect 

Resources What is the Domain Name System (DNS)?

The DNS makes it possible for users to connect to websites using URLs rather than numerical Internet protocol addresses.

What is a DNS server?

DNS servers translate the website domain names users search in web browsers into corresponding numerical IP addresses. This process is known as DNS resolution.

What are DNS records?

A Domain Name System (DNS) record is a set of instructions used to connect domain names with internet protocol (IP) addresses within DNS servers.

What is DNS propagation?

DNS propagation refers to the amount of time that it takes for DNS servers to propagate changes to a DNS record across the internet.

Take the next step

IBM NS1 Connect Managed DNS service delivers resilient, fast, authoritative DNS connections to prevent network outages, and keep your business online, all the time

Explore IBM NS1 Connect Managed DNS Request a live demo