This topic describes how to enable your personal development environment to access the Internet. You will create a NAT Gateway, associate an Elastic IP Address (EIP), and configure Source Network Address Translation (SNAT) in the Virtual Private Cloud (VPC) associated with your environment.
Overview
By default, a personal development environment has Internet access but lacks a fixed egress IP address when not configured within a VPC. If you need a fixed egress IP address, or if your environment is already configured within a VPC, you can use a NAT Gateway. By associating an EIP with the NAT Gateway, you enable your environment to access the Internet through the VPC.
Procedure
-
Create a NAT Gateway. The following table lists the key parameters. For details on other parameters, see NAT Gateway.
If you need to deploy multiple NAT gateways in the same VPC, see Deployment solutions for multiple NAT gateways in the same VPC for network design and deployment guidance.
Parameter
Value
Region
Select the region where your personal development environment is located.
VPC
Select the Proprietary Network and Switch associated with your personal development environment.
To find this information, click Manage Environments in the panel on the left to open the management panel. Expand the instance details to view the associated VPC ID, security group ID, and vSwitch information in the Network Settings section.
vSwitch
Access mode
Select SNAT for All VPC Resources. This option automatically creates an SNAT entry for your VPC.
EIP
Create a new EIP.
Service-Linked Role
If this is the first time you are creating a NAT gateway, you must create a Service-Linked Role. Click Create Service-Linked Role.
-
On the NAT Gateway page, click the name of the gateway that you created to open its General tab. Then, click the SNAT Management tab to verify that the SNAT entry was created.
If the Status column shows Available, the SNAT entry was created successfully. Confirm that the correct VPC ID is displayed in the ECS/ENI/vSwitch/VPC ID column and that the source CIDR block is
0.0.0.0/0.If an SNAT entry was not created, create one. When creating the entry, select Specify VPC and select Single IP. If you have purchased multiple IP addresses, you can select Multiple IP. For more information about creating an SNAT entry, see Use the SNAT feature of a NAT gateway to access the Internet.
-
Verify connectivity.
-
In the top navigation bar, switch to your personal development environment. In the lower-left corner, click
, select Command Palette, and search for Terminal. In the terminal, run the
ping www.aliyun.comcommand to test network connectivity.If you receive response packets, the connection is successful.
The personal development environment can now access the Internet through the NAT gateway.
/mnt/workspace> ping www.aliyun.com PING www.aliyun.com.w.cdngslb.com (183.146.XX.XX): 56 data bytes 64 bytes from 183.146.XX.XX: icmp_seq=0 ttl=53 time=12.245 ms 64 bytes from 183.146.XX.XX: icmp_seq=1 ttl=53 time=12.164 ms 64 bytes from 183.146.XX.XX: icmp_seq=2 ttl=53 time=12.097 ms 64 bytes from 183.146.XX.XX: icmp_seq=3 ttl=53 time=12.127 ms 64 bytes from 183.146.XX.XX: icmp_seq=4 ttl=53 time=12.266 ms 64 bytes from 183.146.XX.XX: icmp_seq=5 ttl=53 time=12.164 ms
-