My IBM Log in Subscribe

What is a CNAME (canonical name) record?

21 February 2024

Authors

Tasmiha Khan

Writer

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.

Aerial view of highways

Keep your head in the cloud 


Get the weekly Think Newsletter for expert guidance on optimizing multicloud settings in the AI era.

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
NS1 Connect

IBM NS1 Connect

Strengthen your network resilience with IBM NS1 Connect. In this video, we discuss the value of IBM NS1 Connect for application resilience and performance.

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

Related solutions

IBM NS1 Connect

IBM NS1 Connect is a fully managed cloud service for enterprise DNS, DHCP, IP address management and application traffic steering.

Explore NS1 Connect
Networking Solutions

Cloud networking solutions from IBM provide high-performing connectivity to power your apps and business.

Explore cloud networking solutions
Networking Support Services

Consolidate datacenter support with IBM Technology Lifecycle Services for cloud networking and more.

Cloud networking services
Take the next step

Strengthen your network resilience with IBM NS1 Connect. Start with a free developer account to explore managed DNS solutions or schedule a live demo to see how our platform can optimize your network's performance and reliability.

Explore Managed DNS Services Book a live demo