Menu Close

What is a DNS CNAME Record?

Posted in Domain Tutorial

A DNS CNAME (Canonical Name) alias is a type of DNS (Domain Name System) record that allows you to map one domain or subdomain to another. It is used to create an alias for a domain, which means that when the DNS resolver encounters a CNAME record for a particular domain or subdomain, it resolves to the domain specified in the CNAME record.

A “canonical name” (CNAME) record points from an alias domain to a “canonical” domain. A CNAME record is used in lieu of an A record, when a domain or subdomain is an alias of another domain. All CNAME records must point to a domain, never to an IP address. Imagine a scavenger hunt where each clue points to another clue, and the final clue points to the treasure. A domain with a CNAME record is like a clue that can point you to another clue (another domain with a CNAME record) or to the treasure (a domain with an A record).

 

CNAME Records
CNAME Records

Here’s how it works:

  1. Alias Creation: You create a CNAME record in your DNS settings for a specific domain or subdomain. This record contains the alias (canonical name) of the target domain.
  2. Resolution: When someone tries to access the domain or subdomain associated with the CNAME record, the DNS resolver looks up the alias specified in the CNAME record.
  3. Redirection: The resolver then resolves the alias to the corresponding IP address or another domain name through additional DNS queries.

For example, if you have a CNAME record for “coolexample.com” pointing to “webserver.coolexample.net,” when someone tries to access “coolexample.com,” the DNS resolver will follow the CNAME record and resolve it to the IP address of “webserver.example.net.”

Related:   What’s an ALIAS Record?

CNAME records are commonly used for creating aliases for services, such as pointing “www” to the actual web server, or creating subdomain aliases for different services. It’s important to note that a CNAME record cannot coexist with other records for the same domain (e.g., A or MX records), and it’s typically used for subdomains or domains that are not hosting other services like mail servers.

How to add a CNAME Record for a PowerHoster Domain

CNAME records use a domain prefix, such as blog or shop, to connect your domain to a different domain name. If you need to add a domain prefix that connects to an IP address, add a subdomain instead.

Example: The most common CNAME is www, with the @ symbol entered for the Value field. This will make www.mycoolnewbusiness.com load to the same webpage as the root domain, mycoolnewbusiness.com.

  1. Sign in to your POWERHOSTER.COM Domain Portfolio. (Need help logging in? Find your username or password.)
  2. Select an individual domain to access the Domain Settings page.
  3. Select DNS to view your DNS records.
  4. Select Add New Record and then select CNAME from the Type menu.
  5. Enter the details for your new CNAME record.
    • Name: The hostname or prefix of the record, without the domain name, such as blog or shop. The Name must follow these guidelines:
      • Periods (.) are allowed but not as the first or last character
      • Consecutive periods (…) are not allowed
      • Cannot exceed 63 characters
      • Cannot be the @ symbol.
      • Not already in use by an existing A record, TXT record or MX record.
    • Value: The URL you are setting as the destination for the host. Type @ to point directly to your root domain name.
    • TTL (Time to Live): The amount of time the server should cache information before refreshing. The default setting is 1 hour.
  6. (Optional) Select Add More Records to add multiple DNS records at the same time. If you change your mind, select screenshot of the icon for deleting a dns record Delete to remove any records that haven’t been saved yet.
  7. Select Save to add your new record. If you added multiple records at the same time, select Save All Records.
Related:   What is a DNS MX record?

Can a CNAME Record Point to Another CNAME Record?

Yes, a CNAME record can point to another CNAME record. This is known as a “CNAME chain” or “CNAME alias of an alias.” When a DNS resolver encounters a CNAME record, it follows the chain until it reaches the final non-CNAME record (such as an A or AAAA record) that provides the actual IP address.

Here’s an example to illustrate:

1. You have a CNAME record like this:Then, you have another CNAME record pointing to the first alias:

alias1.example.com. CNAME target1.example.net.

2. Then, you have another CNAME record pointing to the first alias:

alias2.example.com. CNAME alias1.example.com.

In this scenario, if someone tries to resolve “alias2.example.com,” the DNS resolver will first look up the CNAME record for “alias2.example.com,” which points to “alias1.example.com.” The resolver then looks up the CNAME record for “alias1.example.com,” which points to the final target “target1.example.net.” The resolver will continue this process until it reaches a non-CNAME record.

It’s important to note that while CNAME chaining is technically allowed, excessive chaining can introduce additional DNS resolution delays and may not be the most efficient setup. In some cases, it’s preferable to use direct CNAME records or other types of records, like ALIAS or ANAME records (which are specific to certain DNS providers), especially when pointing to services like content delivery networks (CDNs) that may change their underlying infrastructure.

Leave a Reply