Site-to-Site VPN - Connect to AWS
Connect an OVHcloud VPN gateway to an AWS virtual private gateway over two IPsec tunnels, with static routing or with one BGP session per tunnel
Objective
This guide connects an OVHcloud VPN gateway to an AWS virtual private gateway with AWS Site-to-Site VPN, over two IPsec tunnels. The OVHcloud side is configured from the OVHcloud Console, the AWS side with the AWS CLI.
Site-to-Site VPN is in alpha. The Console offers the regions of your project where it is available: Gravelines (GRA7) during the alpha.
In this guide, you will learn how to:
- connect to AWS with static routing, the two tunnels in active / standby;
- connect to AWS with BGP, one BGP session per tunnel.
Requirements
- A Public Cloud project with Site-to-Site VPN, in a region where it is available (Gravelines (GRA7) during the alpha). The alpha is open, with no sign-up.
- A private subnet of the project in that region, for the VPN gateway, and an instance on it to test the link.
- An AWS account, the AWS CLI configured for it, and the VPC to connect (
<vpc-id>) with its route tables (<rtb-id>: run the route propagation command once per route table of the VPC's subnets). - To test the link, an instance in the VPC whose security group allows ICMP from the local network (
10.1.0.0/24in the examples).
For the objects you create and the limits that apply to them, see Key concepts and Key limits.
OVHcloud Console Access
- Direct link:
- Navigation path:
Public Cloud> Select your project >Network>Site-to-Site VPN
Instructions
This section gives the order of the steps, then one scenario per routing mode. Follow the overview, then the scenario you need: the two scenarios are alternatives for one VPC, not steps to chain.
Contents:
Overview
Both scenarios follow the same order, because each side needs a value from the other: AWS needs the public address of the VPN gateway, and the VPN gateway needs the addresses of the two AWS tunnels.
- On the AWS side, each scenario creates a virtual private gateway and attaches it to the VPC, and AWS attaches one virtual private gateway to a VPC at a time. If the VPC already has one, for example after the other scenario, skip
create-vpn-gatewayandattach-vpn-gatewayand use its ID as<vgw-id>. In scenario B, also use its Amazon-side ASN as the ASN of AWS (aws ec2 describe-vpn-gateways --vpn-gateway-ids <vgw-id> --query 'VpnGateways[0].AmazonSideAsn'), and tunnel inside networks that no other VPN connection of that virtual private gateway uses. - On the OVHcloud side, each scenario creates its own VPN gateway. A VPN gateway holds several IPsec connections, but their remote networks must not overlap: a gateway whose connection already reaches the VPC, for example the other scenario's, refuses a second one to it. And a subnet that already routes the VPC through one VPN gateway keeps that route:
Add the routesleaves it as it is.
- Create the VPN gateway and read its public address.
- Choose a pre-shared key for each tunnel, create the AWS customer gateway, virtual private gateway and VPN connection with them, and read the outside addresses of its two tunnels.
- Create the IPsec connection with its endpoint groups, security proposal and two tunnels, on the VPN gateway.
- Route your OVHcloud instances to the VPC through the VPN gateway, from the connection's recap.
Scenario A: static routing
Two tunnels to an AWS virtual private gateway, statically routed: AWS routes the local networks of the VPN gateway into the VPN connection, and the VPN gateway routes the VPC into its two tunnels, active / standby.
The example uses these values:
Step 1 - Create the VPN gateway and read its public address
Create a VPN gateway as described in Get started in the Console, attaching it to your private subnet on 10.1.0.0/24. Once it is ready, read its public address, <ovhcloud-public-ip> below, from the Public network card of its page.
Step 2 - Create the AWS side
Create the customer gateway, the virtual private gateway and a static VPN connection, with a route to the local network of the VPN gateway. Choose your own pre-shared keys now (<psk-1>, <psk-2>): you will set the same ones on the VPN gateway in Step 3. Each key must suit both sides: AWS takes 8 to 64 letters, digits, periods (.) and underscores (_), not starting with 0, and the Console 16 to 255 printable ASCII characters. Use 16 to 64 letters, digits, periods or underscores, not starting with 0.
Wait until the VPN connection is available (a few minutes) before the next step. The last command returns the outside addresses of the two AWS tunnels, <aws-outside-ip-1> and <aws-outside-ip-2> below.
Step 3 - Create the IPsec connection
Create the IPsec connection as described in Get started in the Console, on the gateway you just created, with these values. For each tunnel's Pre-shared key, select Use my own key, then enter the key you gave AWS: the default, Generate a key, would create a key different from AWS's.
AWS's phase 1 lifetime is 28800 seconds by default, against the Recommended proposal's 10800 seconds; they do not need to match: each side rekeys independently on its own timer.
Step 4 - Route your instances to the VPC
The connection carries traffic only once your OVHcloud instances send the VPC's network to the VPN gateway. The recap of the new connection does it for you:
- On the recap, read the Route the remote networks card:
<subnet> (10.1.0.0/24)·10.52.0.0/16 → <gateway private IP>, the gateway's private IP on your subnet. - Click
Add the routes. A toast confirms 1 host route added., and the button reads Routes added. - Apply the route on your instances: they pick it up at their next DHCP lease renewal, which can take hours, or when they restart. To apply it at once, restart them, or renew the lease on each one (
sudo networkctl renew <interface>on a Linux image that uses systemd-networkd).ip routethen shows10.52.0.0/16 via <gateway private IP> ... proto dhcp.
To add or check the route later, see the Route your instances to the VPN gateway step of the getting-started guide.
How it behaves
-
Both tunnels are established up front: AWS may report the second one
UPa minute after the first. The VPN gateway sends on the best-priority tunnel that is up, and moves to the other one when it fails. It does not move back when the first one recovers (non-preemptive). -
AWS picks the tunnel it sends on by itself and may use the other one; the VPN gateway accepts traffic on either tunnel.
-
When both tunnels are down, traffic to the VPC is dropped, never sent unencrypted.
-
Detection relies on dead peer detection (DPD). The VPN gateway's default action is
restart, and the commands above setrestarton the AWS side too, whose default isclear. A dead peer is declared about 15 s after the first unanswered DPD check, which runs after 30 s of silence by default. -
Compared with Scenario B, any new network on either side means updating the routes by hand:
create-vpn-connection-routeon AWS and, on the VPN gateway, another connection with new endpoint groups, since a connection's endpoint groups are fixed. Its remote networks must not overlap those of the gateway's other connections. -
StartupAction: start(IKEv2 only) makes AWS initiate the tunnels and keep retrying, andDPDTimeoutAction: restartmakes it restart them after a dead peer. Without them AWS only responds, and a tunnel whose negotiation fails (for exampleAUTH_FAILED, as while the VPN connection is stillpending) is retried by neither side: it stays down. To set them on an existing VPN connection (this restarts the tunnel), run this once per tunnel:
Verify scenario A
A tunnel shows Down until both ends agree on every value, pre-shared key included, and the connection shows Degraded while only one of its two tunnels is up. The Console refreshes the status every 30 seconds, for at most 10 minutes, while a tunnel is Down or Unknown and the browser tab is visible.
Scenario B: BGP
Two tunnels to an AWS virtual private gateway, one BGP session each.
The example uses these values:
Step 1 - Create the VPN gateway and read its public address
Create a VPN gateway as described in Get started in the Console, attaching it to your private subnet on 10.1.0.0/24. Once it is ready, read its public address, <ovhcloud-public-ip> below, from the Public network card of its page.
Step 2 - Create the AWS side
Create the customer gateway, the virtual private gateway and the VPN connection, choosing the tunnel inside networks and pre-shared keys you will reuse on the VPN gateway. Each key must suit both sides: AWS takes 8 to 64 letters, digits, periods (.) and underscores (_), not starting with 0, and the Console 16 to 255 printable ASCII characters. Use 16 to 64 letters, digits, periods or underscores, not starting with 0.
Wait until the VPN connection is available (a few minutes) before the next step, and note the outside addresses of its two tunnels:
Step 3 - Create the IPsec connection
Create the IPsec connection as described in Get started in the Console, on the gateway you just created, with these values. For each tunnel's Pre-shared key, select Use my own key, then enter the key you gave AWS: the default, Generate a key, would create a key different from AWS's.
AWS's phase 1 lifetime is 28800 seconds by default, against the Recommended proposal's 10800 seconds; they do not need to match: each side rekeys independently on its own timer. With a transit gateway and VPN ECMP enabled, also turn on the Inbound ECMP switch so that AWS uses both tunnels; with a virtual private gateway, leave it off.
Step 4 - Route your instances to the VPC
The connection carries traffic only once your OVHcloud instances send the VPC's network to the VPN gateway. The recap of the new connection does it for you:
- On the recap, read the Route the remote networks card:
<subnet> (10.1.0.0/24)·10.52.0.0/16 → <gateway private IP>, the gateway's private IP on your subnet. - Click
Add the routes. A toast confirms 1 host route added., and the button reads Routes added. - Apply the route on your instances: they pick it up at their next DHCP lease renewal, which can take hours, or when they restart. To apply it at once, restart them, or renew the lease on each one (
sudo networkctl renew <interface>on a Linux image that uses systemd-networkd).ip routethen shows10.52.0.0/16 via <gateway private IP> ... proto dhcp.
To add or check the route later, see the Route your instances to the VPN gateway step of the getting-started guide.
Notes
-
The remote endpoint group is an envelope: routes learned outside it are ignored, so it must cover every VPC CIDR AWS advertises.
-
All the networks and tunnels of a connection must be of one address family.
-
StartupAction: start(IKEv2 only) makes AWS initiate the tunnels and keep retrying, andDPDTimeoutAction: restartmakes it restart them after a dead peer. Without them AWS only responds, and a tunnel whose negotiation fails (for exampleAUTH_FAILED, as while the VPN connection is stillpending) is retried by neither side: it stays down. To set them on an existing VPN connection (this restarts the tunnel), run this once per tunnel:
Verify scenario B
A tunnel shows Down until both ends agree on every value, pre-shared key included, and the connection shows Degraded while only one of its two tunnels is up. The Console refreshes the status every 30 seconds, for at most 10 minutes, while a tunnel is Down or Unknown and the browser tab is visible.
Limitations
The following rules apply to both scenarios.
Troubleshooting
This table lists the most common cases.
Go further
Join our community of users.