All Products
Search
Document Center

CDN:Add a CNAME record for a domain name

Last Updated:Oct 21, 2024

After you add a domain name to Alibaba Cloud CDN, the system assigns a CNAME to the domain name. You need to add a CNAME record in the system of your DNS service provider to map the domain name to the CNAME. After you add a CNAME record, the acceleration takes effect.

Prerequisites

  1. You have activated CDN. If not, see Activate Alibaba Cloud CDN.

  2. You have added a domain name. If not, see Add a domain name.

Background information

CNAME record

CNAME record (Canonical Name Record) serves to map one domain name to another.

How Alibaba Cloud CDN works

After you add a domain name, Alibaba Cloud CDN assigns a CNAME to the domain name. The CNAME is resolved by the DNS service provider and points to points of presence (POPs). To accelerate content delivery, you need to map the original DNS record of the accelerated domain name, such as example.aliyundoc.com, to the assigned CNAME, such as example.aliyundoc.com.w.kunlunle.com. This way, client requests can be redirected to POPs to speed up access. For more information, see How it works.

Domain name resolution

Domain name resolution is the process of converting a domain name, such as example.aliyundoc.com, into an IP address of the client. For more information, see What is DNS resolution?

Usage notes

If you have configured an A record for the accelerated domain name, to avoid service interruptions, you must verify that the accelerated domain name is accessible by following instructions in (Optional) Test whether a domain name is accessible. Then, disable the A record and map the accelerated domain name to the CNAME.

Step 1: Get the CNAME of the accelerated domain name

Go to the Domain Names page in the Alibaba Cloud CDN console and copy the CNAME of the accelerated domain name.

域名管理

Step 2: Add a CNAME record

The procedure to add a CNAME record varies with your DNS service provider. In this topic, Alibaba Cloud and Tencent Cloud are used as examples.

Important
  • If you add a CNAME record for a wildcard domain such as *.aliyundoc.com, the second-level domains such as example.aliyundoc.com of the wildcard domain can be accelerated, while the third-level domains cannot. For more information, see Does Alibaba Cloud CDN support wildcard domain names?

  • Make sure that the DNS records do not conflict with each other in the same system.

  • The server that Alibaba Cloud CDN uses for domain name resolution is deployed in the Chinese mainland. If you configure region-specific DNS settings for your domain name, for example, you add a CNAME record for your Alibaba Cloud CDN-accelerated domain name only in regions outside the Chinese mainland, including Hong Kong (China), Macao (China), and Taiwan (China), the domain name cannot be mapped to the CNAME. The CNAME status is Pending Configuration in the Alibaba Cloud CDN console. However, acceleration for the domain name is not affected.

  • CNAMEs that are assigned by Alibaba Cloud CDN, DCDN, ApsaraVideo Live, and ApsaraVideo VOD can be used only for domain name resolution. If Alibaba Cloud detects that your CNAME is used for unauthorized or malicious activities, Alibaba Cloud reserves the right to close your Alibaba Cloud account and remove the domain names.

Add a CNAME record on Alibaba Cloud

If your DNS provider is Alibaba Cloud, perform the following steps to add a CNAME record for the domain name:

  1. Log on to the Alibaba Cloud DNS console with the Alibaba Cloud account to which the domain name belongs.

  2. Optional. add a domain name that is not registered with Alibaba Cloud.

    Note

    If the domain name is not registered with Alibaba Cloud, you need to add the domain name to Alibaba Cloud DNS before you can add a DNS record for it. For more information, see Manage domain names. If the domain name is registered with Alibaba Cloud, skip this step.

  3. On the Domain Name Resolution page, find the domain name that you want to manage and click DNS Settings in the Actions column.

  4. Click Add DNS Record and add a CNAME record.

    Note

    The CNAME record of a specific domain name takes precedence over that of a wildcard domain name. If you want to accelerate a wildcard domain, where the DNS record contains an asterisk (*), you need to delete all other DNS records of second-level domains that match the wildcard domain.

    Parameter

    Description

    Example

    Record Type

    Select CNAME.

    CNAME

    Hostname

    • For subdomains, enter the prefix of the subdomain.

    • For wildcard domains, enter *.

    • For root domains, enter @.

    Note

    For more information about subdomains, see Terms.

    • Subdomains:

      • If the domain name to be accelerated is example.aliyundoc.com, enter example.

      • If the domain name to be accelerated is www.example.aliyundoc.com, enter www.example.

    • Wildcard domains:

      • If the domain name to be accelerated is .aliyundoc.com, enter *.

      • If the domain name to be accelerated is *.example.aliyundoc.com, enter *.example.

    • Root domains: If the root domain is aliyundoc.com and the domain name to be accelerated is aliyundoc.com, enter @.

    Note

    Domain name resolution settings apply to the domain name that you register, such as aliyundoc.com, or the left part of the domain name. When you specify the Hostname parameter, enter the part to be resolved. For example, if the domain name to be accelerated is example.aliyundoc.com, enter example.

    DNS Request Source

    Select Default from the drop-down list.

    We recommend that you keep the default setting.

    Record Value

    Enter the CNAME of the domain name.

    Note

    For example, example.aliyundoc.com, and www.example.aliyundoc.com correspond to different CNAMEs. If you want to accelerate a subdomain, add the second-level domain to Alibaba Cloud CDN. Alibaba Cloud then assigns a CNAME to the subdomain. Alternatively, you can add a wildcard domain name to Alibaba Cloud CDN. Subdomains that match the wildcard domain name are mapped to the CNAME of the wildcard domain name. For more information, see Add a domain name.

    www.example.com.w.kunlunsl.com

    TTL

    Enter a time-to-live (TTL) value for the record. A smaller value indicates that the record is updated quicker. The default TTL value is 10 minutes.

    We recommend that you keep the default setting.

  5. Click OK.

Add a CNAME record on Tencent Cloud

If your DNS service provider is Tencent Cloud, perform the following steps to add a CNAME record for the domain name:

  1. Log on to the DNSPod console.

  2. On the DNSPod page, click Add Records and add a CNAME record.

    Parameter

    Description

    Example

    Host

    • For subdomains, enter the prefix of the subdomain.

    • For wildcard domains, enter *.

    • For root domains, enter @.

    Note

    For more information about subdomains, see Terms.

    • Subdomains:

      • If the domain name to be accelerated is example.aliyundoc.com, enter example.

      • If the domain name to be accelerated is www.example.aliyundoc.com, enter www.example.

    • Wildcard domains:

      • If the domain name to be accelerated is .aliyundoc.com, enter *.

      • If the domain name to be accelerated is *.example.aliyundoc.com, enter *.example.

    • Root domains: If the root domain is aliyundoc.com and the domain name to be accelerated is aliyundoc.com, enter @.

    Note

    Domain name resolution settings apply to the domain name that you register, such as aliyundoc.com, or the left part of the domain name. When you specify the Hostname parameter, enter the part to be resolved. For example, if the domain name to be accelerated is example.aliyundoc.com, enter example.

    Type

    Select CNAME.

    CNAME

    Split Zone

    Select Default from the drop-down list.

    We recommend that you keep the default setting.

    Value

    Enter the CNAME of the domain name.

    Note

    For example, example.aliyundoc.com, and www.example.aliyundoc.com correspond to different CNAMEs. If you want to accelerate a subdomain, add the second-level domain to Alibaba Cloud CDN. Alibaba Cloud then assigns a CNAME to the subdomain. Alternatively, you can add a wildcard domain name to Alibaba Cloud CDN. Subdomains that match the wildcard domain name are mapped to the CNAME of the wildcard domain name. For more information, see Add a domain name.

    www.example.com.w.kunlunsl.com

    Weight

    You do not need to set this parameter.

    N/A

    MX

    You do not need to set this parameter.

    N/A

    TTL

    Enter a TTL value for the CNAME record. A smaller value indicates that the record is updated quicker.

    We recommend that you keep the default setting.

  3. Click Confirm.

Step 3: Verify that the CNAME record takes effect

  • Method 1: Use the Alibaba Cloud CDN console

    1. Log on to the Alibaba Cloud CDN console and navigate to the Domain Names page.

    2. Find the domain name and move the pointer over the CNAME Status column. If the CNAME status is Configured, the CNAME has taken effect.image.png

      Note

      If you add a CNAME record, it takes effect immediately. If you modify a CNAME record, it takes 10 minutes for the update to take effect because the default TTL value of a CNAME record is 10 minutes. During this period, the status of the domain name may be displayed as Pending Configuration in the Alibaba Cloud CDN console until the update takes effect. The actual time period varies based on the TTL value that you specify for the CNAME record.

  • Method 2: Run the nslookup command

    1. Start Command Prompt in Windows or Terminal in macOS or Linux.

    2. Run the nslookup -type=CNAME domainName command. If the CNAME in the output is the same as the CNAME that is assigned to the domain name in the Alibaba Cloud CDN console, Alibaba Cloud CDN acceleration takes effect for the domain name.image