Configure Private Zone to resolve a domain name to a private IP address within a VPC.
Workflow
Prerequisites
-
A VPC and a vSwitch have been created. For this tutorial, use the CIDR block
192.168.0.0/16for the VPC and192.168.0.0/24for the vSwitch. Create and delete a VPC and a vSwitch. -
An ECS instance has been created in the VPC to host a demo service. Note its private IP address (for example, 192.168.0.83). Resources within the same VPC (such as
vpc-hangzhou) can access the service atdemo.example.com. Purchase and use an ECS instance.
Procedure
Step 1: Add a zoneUser Defined Zones
-
Sign in to the Alibaba Cloud DNS console for Private Zone.
-
In the left-side navigation pane, choose Authoritative Zone > User Defined Zones. Then, click Add Zone.
-
On the Add Zone page, configure the following parameters.
Authoritative Zone: Enter
example.com.Recursive Resolution Proxy for Subdomain Names: Keep enabled (default).
Leave other parameters at their defaults.
ImportantYou can change the effective scope at any time. We recommend that you configure the scope after adding DNS records.
If a VPC is linked to a zone with no records, DNS queries for the domain from that VPC fail because they are not recursively forwarded to public DNS servers.
Step 2: Add a DNS record
-
Sign in to the Alibaba Cloud DNS console for Private Zone.
-
Navigate to Authoritative Zone > User Defined Zones. Find your zone and click Settings in the Actions column.
-
On the Settings tab, click Add Record and configure the following parameters.
Record Type: Select A.
Hostname: Enter
demo.Record Value: Enter
192.168.0.83.Set Request Source to Default, TTL to 1 Minute, and Record Value Load Balancing Policy to Round-robin.
Step 3: Configure effective scope
-
Sign in to the Alibaba Cloud DNS console for Private Zone.
-
Navigate to Authoritative Zone > User Defined Zones. Find your zone and click Effective Scope in the Actions column.
-
In the Effective Scope panel, select the VPC that you want to associate with this zone.
In the Effective Scope Settings dialog:
-
Effective within Alibaba Cloud VPC: Select the VPCs that you want to associate from the drop-down list (for example, a VPC in the China (Hangzhou) region). You can add multiple VPCs. The + VPC Private Zone DNS Resolution Management (Cross-account) link is provided for cross-account association.
-
Effective within Self-managed DNS Cluster: Select a deployed self-managed DNS cluster from the drop-down list. This is applicable to enterprise IDC private network scenarios. You can click Deploy Now to deploy a cluster.
NoteWe recommend that you set the effective scope after you configure DNS records to avoid resolution failures caused by empty domain names. The VPC data in the drop-down list may have a latency. If the data is not synchronized, try again after 30 minutes.
-
Step 4: Verify resolution
-
Create another ECS instance in the same VPC for testing. Purchase and use an ECS instance.
-
Sign in to the new ECS instance and run the following command:
curl demo.example.comThe following output is displayed:
[ecs-assist-user@iZbp1g6oqu352zapdvhqe0Z ~]$ curl demo.example.com <!DOCTYPE html> <html> <head> <title>HTTP Server Test Page</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to HTTP Server Test Page!</h1> <p>If you see this page, the httpd web server is successfully installed and working. Further configuration is required.</p> <p><em>Thank you for using apache httpd.</em></p> </body> </html>If the correct IP address is returned, the configuration is successful.
If no service is running on the destination instance, run
ping demo.example.comto verify DNS resolution.Example output:
[root@iZbp1xxx ~]# ping demo.example.com PING demo.example.com (192.168.0.83) 56(84) bytes of data. 64 bytes from iZbp17420etyxud5tvupr2Z (192.168.0.83): icmp_seq=1 ttl=64 time=0.014 ms 64 bytes from iZbp17420etyxud5tvupr2Z (192.168.0.83): icmp_seq=2 ttl=64 time=0.025 ms 64 bytes from iZbp17420etyxud5tvupr2Z (192.168.0.83): icmp_seq=3 ttl=64 time=0.026 ms 64 bytes from iZbp17420etyxud5tvupr2Z (192.168.0.83): icmp_seq=4 ttl=64 time=0.025 ms