All Products
Search
Document Center

CDN:(Optional) Test domain name accessibility

Last Updated:Jul 16, 2024

After you add a domain name to Alibaba Cloud CDN, we recommend that you test whether the domain name is accessible before you update the CNAME record of the domain name. This ensures that DNS updates do not affect the services of the domain name. This topic describes how to use an on-premises machine to test whether a domain name is accessible before it is mapped to the CNAME assigned by Alibaba Cloud CDN.

Note

During the test, requests are sent to points of presence (POPs). You are charged for the basic services and value-added services of Alibaba Cloud CDN that you have used. The billing rules of Alibaba Cloud CDN apply in the test. For more information, see Billable items.

Prerequisites

  • A domain name is added to Alibaba Cloud CDN. If you have not added a domain name to Alibaba Cloud CDN, add one to Alibaba Cloud CDN by following instructions in Add a domain name.

  • The origin server that you configure can be accessed.

Procedure

  1. Obtain the CNAME assigned to the domain name.

    1. Log on to the Alibaba Cloud CDN console.

    2. In the left-side navigation pane, click Domain Names.

    3. On the Domain Names page, find the domain name that you want to manage, and copy the CNAME.

      Note

      Copy the CNAME of a domain name that is in the Normal state.

      image

  2. Obtain the IP address of the CNAME. Run the nslookup CNAME of the domain name command in a CLI, such as Command Prompt, PowerShell, or Terminal, to obtain the IP address of the CNAME.

    Note

    The following IP address obtained by running nslookup command is used as an example. The actual IP address of the CNAME obtained by running the nslookup command shall prevail.

    image

  3. Add the IP address and domain name to the hosts file of the on-premises machine.

    You must add the IP address obtained from Step 2 and the accelerated domain name to the hosts file of the on-premises machine. Make sure that you add the IP address before the accelerated domain name.

    In this example, the domain name is example.aliyundoc.com, the CNAME is example.aliyundoc.com.w.kunlunle.com, and the IP address of the CNAME obtained by running nslookup example.aliyundoc.com.w.kunlunle.com is 192.168.0.1.

    Windows

    1. Go the C:\Windows\System32\drivers\etc directory and use Notepad to open the hosts file as the administrator.

    2. Edit the hosts file.

      The file content may be similar to the following text:

      # localhost name resolution is handled within DNS itself.
      # 127.0.0.1       localhost
      # ::1             localhost

      Add the obtained IP address and the domain name to the end of the file. Example:

      192.168.0.1   example.aliyundoc.com
    3. Save the changes.

      After you edit the file, choose File > Save or press Ctrl+S to save changes.

    4. Optional. Refresh the DNS cache to ensure that the DNS resolution changes take effect immediately.

      Open Command Prompt as the administrator and run the following command:

      ipconfig /flushdns

    macOS

    1. Open Terminal and run the following command to open the hosts file as an administrator.

      sudo vim /etc/hosts

      You are prompted to enter the administrator password. Enter the password and press Enter.

    2. Edit the hosts file.

      The file content may be similar to the following text:

      ##
      # Host Database
      #
      # localhost is used to configure the loopback interface
      # when the system is booting.  Do not change this entry.
      ##
      127.0.0.1   localhost
      255.255.255.255 broadcasthost
      ::1         localhost

      Add the obtained IP address and the domain name to the end of the file. Example:

      192.168.0.1   example.aliyundoc.com
    3. Save the changes and exit.

      Press Esc to exit insert mode, enter :wq, and then press Enter to save the file and exit the Vim editor.

    4. Optional. Refresh the DNS cache to ensure that the DNS resolution changes take effect immediately.

      Run the following command in Terminal:

      sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  4. Test whether the accelerated domain name is accessible.

    After you add the IP address and accelerated domain name to the hosts file, you can open the browser and enter the accelerated domain name in the address bar to test the connectivity. You can view the test result by using the developer tool of the browser.

    • If the IP address in the Remote Address field is the same as the one that you add to the hosts file, the configuration is valid. You can configure the CNAME on the DNS service provider side.测试网页连通性

    • If the IP address in the Remote Address field is different from the one that you add to the hosts file, the configuration is invalid. Make sure that you add the IP address of the CNAME to the hosts file.

    After you access the accelerated domain name, you can also test other features by using the on-premises machine.

What to do next

Add a CNAME record for a domain name: After you add a domain name to Alibaba Cloud CDN, Alibaba Cloud CDN assigns a CNAME to the domain name. You need to add the CNAME record for the domain name before Alibaba Cloud CDN acceleration can take effect.