Can Applications Deployed in a VPC Call APIs?
Yes, applications deployed in a VPC can call APIs by default. If domain name resolution fails, configure a DNS server on the current endpoint by following the instructions in Configuring an Intranet DNS Server. After the configuration, applications deployed in the VPC can call APIs.
Configuring an Intranet DNS Server
To configure a DNS server, specify its IP address in the /etc/resolv.conf file.
The IP address of the intranet DNS server depends on which region you are located in. Find the IP address of the intranet DNS server in your region from the private DNS server addresses mentioned in the Domain Name Service FAQs.
Add an intranet DNS server with either of the following two methods:
- Method 1: Modify the subnet information of the VPC.
- Method 2: Edit the /etc/resolv.conf file.
The intranet DNS server configurations become invalid after the ECS restarts, and the intranet DNS server must be configured again. Therefore, method 1 is recommended.
Method 1
Perform the following procedure to add a DNS server IP address to the subnet configurations of the ECS in the VPC.
- Log in to the management console.
- Click in the upper left corner to select a region.
- In the service list, choose Compute > Elastic Cloud Server.
- Click the name of the ECS you want to use.
- On the ECS details page, view the NIC information, and click to view the subnet name of the ECS.
- On the ECS basic information page, view the VPC name of the ECS.
- Click the VPC name to visit the VPC console.
- Choose Subnets in the left navigation pane.
- Locate the subnet mentioned in 5 and click the subnet name.
- Change the DNS server address of the subnet and click OK.
For example, change the address to 100.125.1.250.
- Restart the ECS. Check that the /etc/resolv.conf file contains the IP address of the DNS server to be configured, and the IP address is less than those of all other DNS servers.
The following figure shows the IP address 100.125.1.250 of the DNS server to be configured.
Modifying the subnet information of a VPC will affect all ECSs created using the subnet.
Method 2
Add the IP address of the intranet DNS server to the /etc/resolv.conf file.
For example, if you are located in EU-Dublin, add an intranet DNS server of IP address 100.125.1.250 to the /etc/resolv.conf file.
- The IP address of the new DNS server must be less than those of all other DNS servers.
- The DNS configurations take effect immediately after the /etc/resolv.conf file is saved.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.