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.
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
Obtain the CNAME assigned to the domain name.
Log on to the Alibaba Cloud CDN console.
In the left-side navigation pane, click Domain Names.
On the Domain Names page, find the domain name that you want to manage, and copy the CNAME.
NoteCopy the CNAME of a domain name that is in the Normal state.
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.NoteThe following IP address obtained by running
nslookup
command is used as an example. The actual IP address of the CNAME obtained by running thenslookup
command shall prevail.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 isexample.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
Go the
C:\Windows\System32\drivers\etc
directory and use Notepad to open thehosts
file as the administrator.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
Save the changes.
After you edit the file, choose
or pressCtrl+S
to save changes.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
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.
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
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.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
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.