For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/en/llms-full.txt, and this page is available as Markdown at https://docs.ovhcloud.com/en/guides/public-cloud/network-services/site-to-site-vpn-connect-aws.md.
Skip to content

Site-to-Site VPN - Connect to AWS

View as Markdown

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.

Warning

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/24 in 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-gateway and attach-vpn-gateway and 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 routes leaves it as it is.
  1. Create the VPN gateway and read its public address.
  2. 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.
  3. Create the IPsec connection with its endpoint groups, security proposal and two tunnels, on the VPN gateway.
  4. 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:

ValueExample
Local network (OVHcloud side)10.1.0.0/24
VPC10.52.0.0/16
Pre-shared keys (your own choice, see Step 2)<psk-1>, <psk-2>

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.

aws ec2 create-customer-gateway --type ipsec.1 \
      --public-ip <ovhcloud-public-ip>
aws ec2 create-vpn-gateway --type ipsec.1
aws ec2 attach-vpn-gateway --vpn-gateway-id <vgw-id> --vpc-id <vpc-id>
aws ec2 create-vpn-connection --type ipsec.1 \
      --customer-gateway-id <cgw-id> --vpn-gateway-id <vgw-id> \
      --options '{"StaticRoutesOnly": true, "TunnelOptions": [
        {"PreSharedKey": "<psk-1>",
         "StartupAction": "start", "DPDTimeoutAction": "restart"},
        {"PreSharedKey": "<psk-2>",
         "StartupAction": "start", "DPDTimeoutAction": "restart"}]}'
aws ec2 create-vpn-connection-route --vpn-connection-id <vpn-id> \
      --destination-cidr-block 10.1.0.0/24
aws ec2 enable-vgw-route-propagation --route-table-id <rtb-id> \
      --gateway-id <vgw-id>   # once per route table of the VPC's subnets
aws ec2 describe-vpn-connections --vpn-connection-ids <vpn-id> \
      --query 'VpnConnections[0].State'
aws ec2 describe-vpn-connections --vpn-connection-ids <vpn-id> \
      --query 'VpnConnections[0].Options.TunnelOptions[].OutsideIpAddress'

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.

FieldValue
RoutingStatic
Local endpoint groupNew, CIDR 10.1.0.0/24 (pre-filled from the gateway's subnet)
Remote endpoint groupNew, CIDR 10.52.0.0/16
Security proposalRecommended (IKEv2 · AES-256 · SHA-256 · Group 14)
IPsec tunnelsTwo (recommended)
Tunnel 1 — Peer address<aws-outside-ip-1>
Tunnel 1 — Pre-shared keyUse my own key, <psk-1>: the same key given to AWS in Step 2
Tunnel 2 — Peer address<aws-outside-ip-2>
Tunnel 2 — Pre-shared keyUse my own key, <psk-2>: the same key given to AWS in Step 2

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:

  1. 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.
  2. Click Add the routes. A toast confirms 1 host route added., and the button reads Routes added.
  3. 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 route then shows 10.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 UP a 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 set restart on the AWS side too, whose default is clear. 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-route on 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, and DPDTimeoutAction: restart makes it restart them after a dead peer. Without them AWS only responds, and a tunnel whose negotiation fails (for example AUTH_FAILED, as while the VPN connection is still pending) 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:

    aws ec2 modify-vpn-tunnel-options --vpn-connection-id <vpn-id> \
          --vpn-tunnel-outside-ip-address <aws-outside-ip> \
          --tunnel-options StartupAction=start,DPDTimeoutAction=restart

Verify scenario A

CheckWhereExpected result
The AWS VPN connection is readyaws ec2 describe-vpn-connections --vpn-connection-ids <vpn-id> --query 'VpnConnections[0].State'available
The VPN gateway has its public addressGateway page, Public network cardPublic IPv4 shows an address
The connection and tunnels are upConnection pageUp badge next to the connection's name, two tunnel tiles with the AWS outside addresses as Peer address, each Up
The subnet routes the VPCSubnet page, Host routes card10.52.0.0/16 with the gateway's private IP as Next hop
The tunnels are up on the AWS sideaws ec2 describe-vpn-connections --vpn-connection-ids <vpn-id> --query 'VpnConnections[0].VgwTelemetry[].[OutsideIpAddress,Status]'Both tunnels UP
An OVHcloud instance has the routeOn the instance, ip route show 10.52.0.0/1610.52.0.0/16 via <gateway private IP>
Traffic goes through the tunnelOn the OVHcloud instance, ping <AWS instance private IP>, and the reverse from the AWS instanceReplies in both directions
Info

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:

ValueExample
Local network (OVHcloud side)10.1.0.0/24
VPC10.52.0.0/16
ASN of the VPN gateway65000
ASN of AWS64512
Tunnel inside networks (your own choice)169.254.10.0/30 and 169.254.11.0/30
Inside addressesAWS on .1, the VPN gateway on .2
Pre-shared keys (your own choice, see Step 2)<psk-1>, <psk-2>

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.

aws ec2 create-customer-gateway --type ipsec.1 \
      --public-ip <ovhcloud-public-ip> --bgp-asn 65000
aws ec2 create-vpn-gateway --type ipsec.1 --amazon-side-asn 64512
aws ec2 attach-vpn-gateway --vpn-gateway-id <vgw-id> --vpc-id <vpc-id>
aws ec2 create-vpn-connection --type ipsec.1 \
      --customer-gateway-id <cgw-id> --vpn-gateway-id <vgw-id> \
      --options '{"StaticRoutesOnly": false, "TunnelOptions": [
        {"TunnelInsideCidr": "169.254.10.0/30", "PreSharedKey": "<psk-1>",
         "StartupAction": "start", "DPDTimeoutAction": "restart"},
        {"TunnelInsideCidr": "169.254.11.0/30", "PreSharedKey": "<psk-2>",
         "StartupAction": "start", "DPDTimeoutAction": "restart"}]}'
aws ec2 enable-vgw-route-propagation --route-table-id <rtb-id> \
      --gateway-id <vgw-id>   # once per route table of the VPC's subnets

Wait until the VPN connection is available (a few minutes) before the next step, and note the outside addresses of its two tunnels:

aws ec2 describe-vpn-connections --vpn-connection-ids <vpn-id> \
      --query 'VpnConnections[0].State'
aws ec2 describe-vpn-connections --vpn-connection-ids <vpn-id> \
      --query 'VpnConnections[0].Options.TunnelOptions[].OutsideIpAddress'

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.

FieldValue
RoutingBGP
Local ASN65000
Peer ASN64512
Local endpoint groupNew, CIDR 10.1.0.0/24 (pre-filled from the gateway's subnet)
Remote endpoint groupNew, CIDR 10.52.0.0/16
Security proposalRecommended (IKEv2 · AES-256 · SHA-256 · Group 14)
IPsec tunnelsTwo (recommended)
Tunnel 1 — Peer address<aws-outside-ip-1>
Tunnel 1 — Pre-shared keyUse my own key, <psk-1>: the same key given to AWS in Step 2
Tunnel 1 — BGP tunnel address169.254.10.2/30 (enter it: do not use the pre-filled suggestion, it must match AWS)
Tunnel 1 — BGP peer address169.254.10.1
Tunnel 2 — Peer address<aws-outside-ip-2>
Tunnel 2 — Pre-shared keyUse my own key, <psk-2>: the same key given to AWS in Step 2
Tunnel 2 — BGP tunnel address169.254.11.2/30 (enter it: do not use the pre-filled suggestion, it must match AWS)
Tunnel 2 — BGP peer address169.254.11.1

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:

  1. 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.
  2. Click Add the routes. A toast confirms 1 host route added., and the button reads Routes added.
  3. 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 route then shows 10.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, and DPDTimeoutAction: restart makes it restart them after a dead peer. Without them AWS only responds, and a tunnel whose negotiation fails (for example AUTH_FAILED, as while the VPN connection is still pending) 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:

    aws ec2 modify-vpn-tunnel-options --vpn-connection-id <vpn-id> \
          --vpn-tunnel-outside-ip-address <aws-outside-ip> \
          --tunnel-options StartupAction=start,DPDTimeoutAction=restart

Verify scenario B

CheckWhereExpected result
The AWS VPN connection is readyaws ec2 describe-vpn-connections --vpn-connection-ids <vpn-id> --query 'VpnConnections[0].State'available
The VPN gateway has its public addressGateway page, Public network cardPublic IPv4 shows an address
The connection and tunnels are upConnection pageUp badge next to the connection's name, two tunnel tiles with the AWS outside addresses as Peer address, each Up
The subnet routes the VPCSubnet page, Host routes card10.52.0.0/16 with the gateway's private IP as Next hop
The tunnels are up on the AWS sideaws ec2 describe-vpn-connections --vpn-connection-ids <vpn-id> --query 'VpnConnections[0].VgwTelemetry[].[OutsideIpAddress,Status]'Both tunnels UP
An OVHcloud instance has the routeOn the instance, ip route show 10.52.0.0/1610.52.0.0/16 via <gateway private IP>
Traffic goes through the tunnelOn the OVHcloud instance, ping <AWS instance private IP>, and the reverse from the AWS instanceReplies in both directions
Info

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.

LimitationDetails
Tunnels per connectionA connection holds at most two tunnels.
Peer networksThey may not be a default route, nor contain the address of a peer.
Connections per VPN gatewayA VPN gateway holds several connections. Their remote networks must not overlap, and its BGP connections share one local ASN.
Changes while busyWhile the VPN gateway is being created, updated or deleted, it cannot be selected for a new connection, and creating, updating or deleting its tunnels is refused: retry once it is ready.

Troubleshooting

This table lists the most common cases.

IssuePossible causeSolution
A tunnel stays downAWS only responds, and the first negotiation failed (for example AUTH_FAILED while the AWS VPN connection was still pending)Set StartupAction=start,DPDTimeoutAction=restart on the tunnel with aws ec2 modify-vpn-tunnel-options
The tunnels are up but instances cannot reach the VPCThe subnet has no host route to the VPC, or the instances have not picked it up yetClick Add the routes on the connection's recap, or add the route from the subnet's page. Then restart the instances or renew their DHCP lease
AWS instances cannot reach the OVHcloud instancesThe VPC route tables do not propagate the virtual private gateway's routes, or the security group refuses the trafficRun enable-vgw-route-propagation for each route table of the VPC's subnets, and allow the local network in the security group
The VPN gateway cannot be selected when you create the IPsec connectionThe gateway is still being created, or has no public IP yet: the list shows Creating — no public IP yet or No public IP yetWait until the gateway's Public network card shows the address, then retry
(BGP) Routes of the VPC are missing on the OVHcloud sideThe routes are outside the remote endpoint group, which ignores themMake the remote endpoint group cover every VPC CIDR AWS advertises

Go further

Join our community of users.

Was this page helpful?