All Products
Search
Document Center

VPN Gateway:Use IPsec-VPN to connect Alibaba Cloud VPCs to Amazon VPCs

Last Updated:May 16, 2024

This topic describes how to establish IPsec-VPN connections to enable communication between Alibaba Cloud Virtual Private Cloud (VPC) and Amazon Virtual Private Cloud (Amazon VPC).

Example

In this example, an enterprise creates a VPC in the Germany (Frankfurt) region of Alibaba Cloud and also a VPC in the Europe (Frankfurt) region of Amazon Web Services (AWS). The enterprise wants the Alibaba Cloud VPC and the Amazon VPC to communicate with each other.

The enterprise can use a public VPN gateway of Alibaba Cloud VPN Gateway and AWS VPN to establish IPsec-VPN connections between the two VPCs to enable encrypted communication between the two VPCs.VPN对接AWS VPN-场景示例.png

Prerequisites

  • A VPC is created in the Germany (Frankfurt) region of Alibaba Cloud. Resources are deployed on Elastic Compute Service (ECS) instances in the VPC. For more information, see Create a VPC with an IPv4 CIDR block.

  • A VPC is created in the Europe (Frankfurt) region of AWS. Resources are deployed on Amazon Elastic Compute Cloud (Amazon EC2) instances in the VPC. For more information, visit AWS.

ProcedureAWS和阿里云-配置流程.png

Step 1: Create a VPN gateway on Alibaba Cloud

You must first create a VPN gateway on Alibaba Cloud. After the VPN gateway is created, the system allocates two IP addresses to the VPN gateway. The IP addresses are used to establish IPsec-VPN connections to AWS.

  1. Log on to the VPN Gateway console.

  2. In the top navigation bar, select the region where you want to create the VPN gateway.

    The region of the VPN gateway must be the same as that of the VPC to be associated.

  3. On the VPN Gateway page, click Create VPN Gateway.

  4. On the buy page, configure the following parameters, click Buy Now, and then complete the payment.

    Parameter

    Description

    Example

    Name

    The name of the VPN gateway.

    Enter VPN Gateway.

    Resource Group

    The resource group to which the VPN gateway belongs.

    If you leave this parameter empty, the VPN gateway belongs to the default resource group.

    Leave this parameter empty.

    Region

    The region in which you want to create the VPN gateway.

    Select Germany (Frankfurt).

    Gateway Type

    The type of the VPN gateway.

    Select Standard.

    Network Type

    The network type of the VPN gateway.

    Select Public.

    Tunnels

    The tunnel mode of the VPN gateway. The system displays the tunnel modes that are supported in this region. Valid values:

    • Dual-tunnel

    • Single-tunnel

    For more information about the single-tunnel mode and dual-tunnel mode, see [Upgrade notice] IPsec-VPN connections support the dual-tunnel mode.

    Use the default value Dual-tunnel.

    VPC

    The VPC with which you want to associate the VPN gateway.

    Select a VPC in the Germany (Frankfurt) region.

    VSwitch

    The vSwitch with which you want to associate the VPN gateway in the associated VPC.

    • If you select Single-tunnel, you need to specify only one vSwitch.

    • If you select Dual-tunnel, you need to specify two vSwitches.

    Note
    • By default, the system selects a vSwitch. You can change or use the default vSwitch.

    • After you create a VPN gateway, you cannot change the vSwitch that is associated with the VPN gateway. You can view the associated vSwitch and the zone of the vSwitch on the details page of the VPN gateway.

    Select a vSwitch in the associated VPC.

    vSwitch 2

    The other vSwitch with which you want to associate the VPN gateway in the associated VPC.

    • Specify two vSwitches in different zones in the associated VPC to implement disaster recovery across zones for IPsec-VPN connections.

    • For a region that supports only one zone, disaster recovery across zones is not supported. We recommend that you specify two vSwitches in the zone to implement high availability of IPsec-VPN connections. You can also select the same vSwitch as the first one.

    Note

    If only one vSwitch is deployed in the VPC, create a vSwitch. For more information, see Create and manage a vSwitch.

    Select another vSwitch in the associated VPC.

    Maximum Bandwidth

    The maximum bandwidth of the VPN gateway. Unit: Mbit/s.

    Use the default value.

    Traffic

    The metering method of the VPN gateway. Default value: Pay-by-data-transfer.

    For more information, see Billing.

    Use the default value.

    IPsec-VPN

    Specifies whether to enable IPsec-VPN for the VPN gateway. Default value: Enable.

    Select Enable.

    SSL-VPN

    Specifies whether to enable SSL-VPN for the VPN gateway. Default value: Disable.

    Select Disable.

    Duration

    The billing cycle of the VPN gateway. Default value: By Hour.

    Use the default value.

    Service-linked Role

    The service-linked role of VPN Gateway. Click Create Service-linked Role. The system automatically creates the service-linked role AliyunServiceRoleForVpn.

    The VPN gateway assumes this role to access other cloud resources. For more information, see AliyunServiceRoleForVpn.

    If Created is displayed, the service-linked role is created, and you do not need to create it again.

    Configure this parameter based on your business requirements.

  5. After the VPN gateway is created, you can view the VPN gateway on the VPN Gateway page.

    The newly created VPN gateway is in the Preparing state and changes to the Normal state after about 1 to 5 minutes. After the status changes to Normal, the VPN gateway is ready for use.

    The following table describes the two IP addresses allocated by the system to the VPN gateway.

    VPN gateway name

    VPN gateway ID

    IP address

    VPN Gateway

    vpn-gw8dickm386d2qi2g****

    IPsec Address 1: 47.XX.XX.46, which is the IP address of the active tunnel by default.

    IPsec Address 2: 47.XX.XX.31, which is the IP address of the standby tunnel by default.

Step 2: Deploy VPN resources on AWS

To establish IPsec-VPN connections between the Amazon VPC and the Alibaba Cloud VPC, you must deploy VPN resources on AWS based on the following information. Consult AWS for specific commands or operations.

  1. Create customer gateways.

    You must create two customer gateways on AWS and use the IP addresses of the Alibaba Cloud VPN gateway as the IP addresses of the customer gateways.AWS客户网关.png

  2. Create a virtual private gateway.

    You must create a virtual private gateway on AWS and associate the virtual private gateway with the Amazon VPC that needs to communicate with Alibaba Cloud.AWS虚拟私有网关.png

  3. Create Site-to-Site VPN connections.

    Important

    Alibaba Cloud and AWS IPsec-VPN connections support the dual-tunnel mode. By default, the two tunnels of an AWS IPsec-VPN connection are associated with the same customer gateway, and the two tunnels of an Alibaba Cloud IPsec-VPN connection have different IP addresses. Therefore, the two tunnels of AWS are connected to only one tunnel of Alibaba Cloud. To ensure that the two tunnels of the Alibaba Cloud IPsec-VPN connection are enabled at the same time, you must create two Site-to-Site VPN connections on AWS and associate the Site-to-Site VPN connections with different customer gateways.

    The following figure shows the configurations of one of the Site-to-Site VPN connections. We recommend that you use the default values for the tunnel configurations. Specify a different customer gateway when you configure the other Site-to-Site VPN connection. Use the same values for other parameters.AWS创建VPN连接.png

    After the Site-to-Site VPN connections are created, you can view the tunnel addresses of the connections, which are used to create IPsec-VPN connections to Alibaba Cloud.AWS隧道IP地址.png

    The following table describes the external IP address for each tunnel and the IP address of the associated customer gateway.

    Site-to-Site VPN connection

    Tunnel

    External IP address

    Associated customer gateway IP address

    Site-to-Site VPN Connection 1

    Tunnel 1

    18.XX.XX.161

    47.XX.XX.46

    Tunnel 2

    18.XX.XX.185

    Site-to-Site VPN Connection 2

    Tunnel 1

    3.XX.XX.9

    47.XX.XX.31

    Tunnel 2

    3.XX.XX.250

  4. Configure route advertising.

    You must enable route advertising for the route table of the Amazon VPC that is associated with the virtual private gateway to ensure that the routes of the Site-to-Site VPN connections are automatically advertised to the route table of the Amazon VPC.AWS路由传播.png

Step 3: Deploy the VPN gateway on Alibaba Cloud

After you configure VPN resources on AWS, deploy a VPN gateway on Alibaba Cloud based on the following information to establish IPsec-VPN connections between the Amazon VPC and the Alibaba Cloud VPC.

  1. Create customer gateways.

    1. Log on to the VPN Gateway console.

    2. In the left-side navigation pane, choose Interconnections > VPN > Customer Gateways.

    3. In the top navigation bar, select the region in which you want to create the customer gateway.

      Make sure that the customer gateway and the VPN gateway to be connected are deployed in the same region.

    4. On the Customer Gateways page, click Create Customer Gateway.

    5. In the Create Customer Gateway panel, configure the following parameters and click OK.

      You must create two customer gateways on Alibaba Cloud and use the external IP addresses of the tunnels of the AWS Site-to-Site VPN connections as the IP addresses of the customer gateways. The following table describes only the parameters that are relevant to this topic. You can use the default values for other parameters or leave them empty. For more information, see Create and manage a customer gateway.

      Important

      Use only the external IP address of Tunnel 1 of each Site-to-Site VPN connection as the IP address of a customer gateway. By default, the external IP address of Tunnel 2 of each Site-to-Site VPN connection is not used. After the IPsec-VPN connections are created, Tunnel 2 of each Site-to-Site VPN connection is unavailable.

      Parameter

      Description

      Customer Gateway 1

      Customer Gateway 2

      Name

      The name of the customer gateway.

      Enter Customer Gateway 1.

      Enter Customer Gateway 2.

      IP Address

      The external IP address of the AWS tunnel.

      Enter 18.XX.XX.161.

      Enter 3.XX.XX.9.

  2. Create an IPsec-VPN connection.

    1. In the left-side navigation pane, choose Interconnections > VPN > IPsec Connections.

    2. In the top navigation bar, select the region in which you want to create the IPsec-VPN connection.

      Make sure that the IPsec-VPN connection and the VPN gateway are in the same region.

    3. On the IPsec Connections page, click Create IPsec-VPN Connection.

    4. On the Create IPsec-VPN Connection page, configure the IPsec-VPN connection based on the following information and click OK.

      Parameter

      Description

      Example

      Name

      The name of the IPsec-VPN connection.

      Enter IPsec-VPN Connection.

      Resource Group

      The resource group to which the VPN gateway belongs.

      Select the default resource group.

      Associate Resource

      The type of the network resource that you want to associate with the IPsec-VPN connection.

      Select VPN Gateway.

      VPN Gateway

      The VPN gateway that you want to associate with the IPsec-VPN connection.

      Select the VPN gateway that you created.

      Routing Mode

      The routing mode of the traffic. Valid values:

      • Destination Routing Mode: forwards traffic based on the destination IP address.

      • Protected Data Flows: forwards traffic based on the source and destination IP addresses.

      Select Protected Data Flows.

      Local Network

      The CIDR block of the VPC with which the VPN gateway is associated.

      Enter 10.0.0.0/16.

      Remote Network

      The peer CIDR block that the VPC associated with the VPN gateway wants to access.

      Enter 192.168.0.0/16.

      Effective Immediately

      Specifies whether to immediately start negotiations for the connection. Valid values:

      • Yes: starts negotiations after the configuration is complete.

      • No: starts negotiations when inbound traffic is detected.

      Select Yes.

      Enable BGP

      Specifies whether to enable Border Gateway Protocol (BGP). If you want to use BGP routing for the IPsec-VPN connection, turn on Enable BGP. By default, Enable BGP is turned off.

      Turn off Enable BGP.

      Tunnel 1

      Configure VPN parameters for the active tunnel.

      By default, Tunnel 1 serves as the active tunnel and Tunnel 2 serves as the standby tunnel. You cannot modify this configuration.

      Customer Gateway

      The customer gateway that you want to associate with the active tunnel.

      Select Customer Gateway 1.

      Pre-Shared Key

      The pre-shared key of the active tunnel that is used to verify identities.

      • The pre-shared key must be 1 to 100 characters in length, and can contain digits, letters, and the following characters: ~ ` ! @ # $ % ^ & * ( ) _ - + = { } [ ] \ | ; : ' , . < > / ?

      • If you do not specify a pre-shared key, the system generates a random 16-character string as the pre-shared key.

      Important

      The tunnel and the peer gateway device must use the same pre-shared key. Otherwise, the system cannot establish an IPsec-VPN connection.

      Use the same pre-shared key as the key of the AWS tunnel to be connected.

      Encryption Configuration

      Configure the parameters for the Internet Key Exchange (IKE), IPsec, dead peer detection (DPD), and NAT traversal features.

      • The value of the SA Life Cycle (seconds) parameter in the IKE Configurations section must be the same as the value specified on AWS. In this example, the value is set to 28800.

      • The value of the SA Life Cycle (seconds) parameter in the IPsec Configurations section must be the same as the value specified on AWS. In this example, the value is set to 3600.

      Use the default values for other parameters. For more information, see Create and manage IPsec-VPN connections in dual-tunnel mode.

      Tunnel 2

      Configure VPN parameters for the standby tunnel.

      Customer Gateway

      The customer gateway that you want to associate with the standby tunnel.

      Select Customer Gateway 2.

      Pre-Shared Key

      The pre-shared key of the standby tunnel that is used to verify identities.

      Use the same pre-shared key as the key of the AWS tunnel to be connected.

      Encryption Configuration

      Configure the parameters for the IKE, IPsec, DPD, and NAT traversal features.

      • The value of the SA Life Cycle (seconds) parameter in the IKE Configurations section must be the same as the value specified on AWS. In this example, the value is set to 28800.

      • The value of the SA Life Cycle (seconds) parameter in the IPsec Configurations section must be the same as the value specified on AWS. In this example, the value is set to 3600.

      Use the default values for other parameters. For more information, see Create and manage IPsec-VPN connections in dual-tunnel mode.

      Tags

      The tags of the IPsec-VPN connection.

      Leave this parameter empty.

    5. In the Created message, click OK.

  3. Advertise the route of the VPN gateway.

    After you create the IPsec-VPN connection, you must advertise the route of the VPN gateway. If you select Protected Data Flows as Routing Mode, the system creates a policy-based route for the VPN gateway after the IPsec-VPN connection is created. The route is in the Unpublished state. You must advertise the policy-based route of the VPN gateway to the VPC.

    1. In the left-side navigation pane, choose Interconnections > VPN > VPN Gateways.

    2. In the top navigation bar, select the region in which the VPN gateway resides.

    3. On the VPN Gateways page, find the VPN gateway that you want to manage and click its ID.

    4. On the details page of the VPN gateway, click the Policy-based Route Table tab, find the route that you want to manage, and then click Advertise in the Actions column.

    5. In the Advertise Route message, click OK.

Step 4: Test the connectivity

After the configuration is complete, an IPsec-VPN connection is established between the Alibaba Cloud VPC and the Amazon VPC. The following example uses an ECS instance to access an Amazon EC2 instance to test the connectivity between the VPCs.

Note

Before you test the connectivity, check the access control policies applied to resources in the VPCs, such as network access control lists (ACLs) and security group rules. Make sure that the access control policies allow resources in the VPCs to access each other.

  1. Log on to an ECS instance in the Alibaba Cloud VPC. For more information about how to log on to an ECS instance, see Connection method overview.

  2. Run the ping command on the ECS instance to access the Amazon EC2 instance and check the connectivity.

    If the ECS instance receives a response from the Amazon EC2 instance, the VPCs can communicate with each other.

    ping <Private IP address of the Amazon EC2 instance>

    AWS连通性.png

  3. Test the high availability of the IPsec-VPN connection.

    An IPsec-VPN connection in dual-tunnel mode provides high service availability. If the active tunnel is down, the standby tunnel automatically takes over to ensure the data transfer. The following section describes how to verify the high availability of an IPsec-VPN connection in dual-tunnel mode.

    1. Log on to the ECS instance in the Alibaba Cloud VPC.

    2. Run the following command on the ECS instance to access the Amazon EC2 instance:

      ping <Private IP address of the Amazon EC2 instance> -c 10000
    3. Interrupt the active tunnel of the IPsec-VPN connection.

      In this example, the pre-shared key of the active tunnel on the Alibaba Cloud side is modified to interrupt the active tunnel. If the pre-shared keys of the two sides of an active tunnel are inconsistent, the active tunnel is interrupted.

    4. Check the traffic of the ECS instance. In this example, the traffic of the ECS instance is temporarily interrupted and then restored, which indicates that the standby tunnel takes over when the active tunnel is interrupted.

      You can view the monitoring data of the tunnels on the Monitor tab of the IPsec-VPN connection. For more information, see Monitor an IPsec-VPN connection.