An IPsec VPN is the fastest way to connect an office or data centre to the cloud. Cloud VPN connections come with two tunnels that terminate on different provider endpoints. Adding a second customer device and running BGP over every tunnel means a failed tunnel, device or provider endpoint is routed around in seconds, with no manual change.
- Detect
- Analyze
- Resolve
When to use it
- Connecting offices or data centres to the cloud
- Backup path for a dedicated interconnect
- Partner connectivity with modest bandwidth
When to avoid it
- Sustained multi-gigabit traffic: each tunnel has a throughput limit
- Latency-sensitive traffic where internet jitter matters
How traffic flows
- Create two VPN connections, one per customer firewall. Each has two tunnels to different provider endpoints: four tunnels in total.
- Run a BGP session over every tunnel. The data centre advertises its ranges; the cloud side advertises VPC ranges.
- Use AS-path prepending or MED to prefer one firewall, so traffic is symmetric under normal conditions.
- Tune dead peer detection and BGP timers so a failed tunnel is withdrawn quickly.
Configuration examples
resource "aws_customer_gateway" "fw1" {
bgp_asn = 65010
ip_address = "203.0.113.10"
type = "ipsec.1"
}
resource "aws_vpn_connection" "dc_fw1" {
customer_gateway_id = aws_customer_gateway.fw1.id
transit_gateway_id = aws_ec2_transit_gateway.hub.id
type = "ipsec.1"
tunnel1_ike_versions = ["ikev2"]
tunnel1_phase1_encryption_algorithms = ["AES256-GCM-16"]
tunnel1_dpd_timeout_action = "restart"
tunnel2_ike_versions = ["ikev2"]
tunnel2_phase1_encryption_algorithms = ["AES256-GCM-16"]
tunnel2_dpd_timeout_action = "restart"
}
# repeat for fw2 with its own customer gatewayrouter bgp 65010
bgp router-id 203.0.113.10
neighbor 169.254.10.1 remote-as 64512
neighbor 169.254.10.1 timers 10 30
neighbor 169.254.11.1 remote-as 64512
neighbor 169.254.11.1 timers 10 30
address-family ipv4 unicast
network 172.16.0.0/12
neighbor 169.254.10.1 route-map PREFER-IN out
exit-address-family
!
route-map PREFER-IN permit 10
set as-path prepend 65010 ! on fw2 only: makes fw1 preferredExamples are starting points. Review provider limits, names and versions for your environment before applying.
What to monitor
| Signal | Why it matters |
|---|---|
| Tunnel state and BGP session state | Four tunnels should be up; two down means you have lost redundancy, not service. |
| Routes received per session | A session that is up but receives no routes carries no traffic. |
| Tunnel throughput against its limit | Saturation shows up as packet loss well before an outage. |
| Rekey and DPD events | Frequent rekeys point at mismatched lifetimes. |
Common failure modes
Running on one tunnel for weeks
Redundancy was lost long ago and nobody noticed.
Pulse alerts the moment tunnel count drops below the expected number.
Asymmetric routing through two firewalls
Stateful firewalls drop return traffic.
Lens correlates firewall drops with BGP path preference changes.