Skip to main content

Cloud VPN

Exam guide§2.3

Cloud VPN securely connects an on-premises (or other-cloud) network to your VPC over an IPsec tunnel across the public internet: one gateway encrypts the traffic, the other decrypts it. Google Cloud offers two gateway types - Classic VPN (every gateway created before HA VPN existed) and HA VPN. Dynamic routes on either type are handled by Cloud Router.

Classic VPN

Classic VPN topology: VPC with us-east1/us-west1 subnets connected through a Cloud VPN gateway over the internet to an on-premises VPN gateway and its subnets.
Classic VPN joins your VPC to an on-premises network over a pair of IPsec tunnels across the public internet. The Cloud VPN gateway is a regional resource with a regional external IP; the peer gateway can be any hardware or software VPN device.

Useful for low-volume data connections. You configure a Cloud VPN gateway, a peer (on-premises) VPN gateway, and two VPN tunnels - each tunnel defines the connection from the perspective of its own gateway, and traffic only flows once the pair is up.

NumbersClassic VPN facts
  • 99.9% availability SLA (managed service).
  • Supports site-to-site VPN, static and dynamic routes, and IKEv1 / IKEv2 ciphers.
  • The Cloud VPN gateway is regional and uses a regional external IP.
  • The peer gateway is a physical device in your data center, or a physical/software VPN in another cloud provider - it also has an external IP.
GotchaNo client dial-in

Classic VPN is site-to-site only. It does not support client computers "dialing in" to the VPN with client VPN software.

GotchaOn-premises MTU cannot exceed 1460 bytes

Because of packet encryption and encapsulation overhead, the MTU of your on-premises VPN gateway must be ≤ 1460 bytes. A larger MTU causes fragmentation/drops.

HA VPN

HA VPN is the high-availability solution: it connects on-premises to your VPC through an IPsec connection in a single region with a 99.99% SLA.

NumbersHA VPN facts
  • 99.99% SLA - only when you configure two (or four) tunnels to your peer.
  • The gateway has exactly two interfaces; Google Cloud auto-assigns two external IPs, one per interface, each from a unique address pool. Deleting the gateway releases the IPs for reuse.
  • Each interface supports multiple tunnels, and you can create multiple HA VPN gateways.
  • Tunnels must use dynamic (BGP) routing via Cloud Router.
  • Route priorities decide an active/active or active/passive configuration.
GotchaOne interface = no 99.99% SLA

You can configure an HA VPN gateway with a single active interface / one external IP, but that configuration does not qualify for the 99.99% availability SLA.

HA VPN supports site-to-site VPN in three recommended topologies, explored below.

Topology 1: HA VPN to peer VPN gateways

HA VPN gateway with two interfaces, each with a regional external IP and a Cloud Router BGP session, connecting through the internet to two on-premises VPN gateways.
HA VPN to two separate peer devices (REDUNDANCY_TYPE = TWO_IPS_REDUNDANCY): interface 0 and interface 1 each get a Google-assigned regional external IP, one VPN tunnel runs to each peer gateway, and Cloud Router opens a BGP session per interface over the link-local IPs. This is the 99.99%-SLA configuration.

There are three peer-gateway arrangements: to two separate peer devices (each with its own IP), to one peer device with two IPs, or to one peer device with one IP. A second physical peer gateway gives you redundancy and failover - you can take one offline for maintenance and stay protected against a device failure.

GotchaTWO_IPS_REDUNDANCY

The two-separate-peer-devices arrangement sets REDUNDANCY_TYPE = TWO_IPS_REDUNDANCY and delivers 99.99% availability.

Topology 2: HA VPN to AWS

HA VPN to AWS: an AWS transit gateway or virtual private gateway with four public IPs connects over the internet to the two interfaces of a Google Cloud HA VPN gateway, Cloud Router, and VPC routing.
HA VPN to AWS uses four tunnels: two AWS VPN connections, each with two public IPs, terminate on the two HA VPN interfaces. An external VPN gateway resource in Google Cloud represents the AWS side. Only an AWS transit gateway supports ECMP.

Three components: an HA VPN gateway (two interfaces) in Google Cloud, two AWS virtual private gateways, and an external VPN gateway resource in Google Cloud that describes the AWS side. The supported configuration uses four tunnels - two from each AWS VPN connection to each HA VPN interface.

GotchaOnly the AWS transit gateway supports ECMP

You can peer with either an AWS transit gateway or a virtual private gateway, but only the transit gateway supports ECMP (equal-cost multipath), which distributes traffic equally across active tunnels.

Topology 3: HA VPN between two Google Cloud networks

Two Google Cloud projects, each with an HA VPN gateway and Cloud Router, cross-connected interface 0 to interface 0 and interface 1 to interface 1 over the Google production network.
To join two VPCs, put an HA VPN gateway plus a Cloud Router in each network and build two tunnels per side (interface 0 to interface 0, interface 1 to interface 1). Traffic rides the Google production network - not the public internet - and BGP exchanges routes for a 99.99% SLA.

Put an HA VPN gateway in each VPC and create two tunnels per gateway: connect interface 0 to interface 0 and interface 1 to interface 1. This provides 99.99% availability.

Building an HA VPN: resource order

The lab builds this end state - a simulated on-premises VPC and a global VPC joined by HA VPN:

Google Cloud HA-VPN lab: VPC on-prem (Cloud VPN, Cloud Router, on-prem-subnet1 with a VM) connected over the internet by two dashed HA VPN tunnels to the Global VPC vpc-demo, which spans us-central1 (Cloud VPN, Cloud Router, vpc-demo-subnet1) and us-east1 (vpc-demo-subnet2).
The lab you build: a simulated on-premises VPC (on-prem) and a Global VPC (vpc-demo) spanning us-central1 and us-east1. Each side runs a Cloud VPN gateway and a Cloud Router; the dashed lines are the HA VPN tunnels across the internet (two per side - one per gateway interface). Global routing lets on-prem reach vpc-demo-subnet2 in the other region.

You cannot create these resources in any order - each one needs the resource above it to already exist. The diagram reads top-down: everything hangs off the VPC network, and the routing pieces stack up one prerequisite at a time.

1 - Network2 - In the VPC3 - Compute + tunnels4 - Interfaces5 - BGP peeringVPC network(custom mode)SubnetsFirewallrulesHA VPNgatewayCloudRouterVMinstancesVPNtunnelsRouterinterfaceBGP peer
Creation order for an HA VPN (one side). Each level requires the level above: the VPC comes first; subnets, firewall rules, the HA VPN gateway, and the Cloud Router all attach to it; a tunnel binds a gateway interface; a router interface is added for that tunnel; then a BGP peer sits on the interface.

The connectors show each resource's main prerequisite, but three resources need more than one input:

  • VPN tunnel binds a gateway interface + a Cloud Router + the peer gateway (--vpn-gateway, --router, --peer-gcp-gateway). Build two per side - interface 0 to interface 0, interface 1 to interface 1.
  • Router interface is added to the Cloud Router and points at a tunnel, using a link-local IP from 169.254.0.0/16.
  • BGP peer is added to the Cloud Router on that interface, with the remote gateway's ASN.
GotchaFirewall rules are not on the critical path

Subnets, firewall rules, the VPN gateway, and the Cloud Router only depend on the VPC, so they can be created in any order relative to each other. But the tunnel -> interface -> BGP peer chain is strictly ordered.

The 9 steps, in order

The dependency tree collapses to one linear command sequence you run per VPN side - each step is a gcloud compute create:

1VPC network
2Subnets
3Firewall rules
4VM instances
5HA VPN gateway
6Cloud Router
7VPN tunnels
8Router interfaces
9BGP peers
Creation order for one HA VPN side, as a single left-to-right sequence. Each step is one gcloud compute create; colors group the five build phases (network, workloads, VPN core, tunnels, routing).
  1. VPC network - networks create ... --subnet-mode custom
  2. Subnets - networks subnets create ... --range ... --region ...
  3. Firewall rules - firewall-rules create ... (allow-custom, allow-ssh-icmp)
  4. VM instances - instances create ... --subnet ...
  5. HA VPN gateway - vpn-gateways create ... --network ... --region ...
  6. Cloud Router - routers create ... --asn ...
  7. VPN tunnels - vpn-tunnels create ... --vpn-gateway ... --router ... --peer-gcp-gateway ... --interface 0|1
  8. Router interfaces - routers add-interface ... --vpn-tunnel ... --ip-address 169.254.x.x
  9. BGP peers - routers add-bgp-peer ... --peer-asn ...

Spelled out, one command per step (values from the lab, vpc-demo side):

CommandsHA VPN build order (one side)
# 1 - VPC network
gcloud compute networks create vpc-demo --subnet-mode custom
 
# 2 - Subnet
gcloud compute networks subnets create vpc-demo-subnet1 \
--network vpc-demo --range 10.1.1.0/24 --region us-east1
 
# 3 - Firewall rules
gcloud compute firewall-rules create vpc-demo-allow-custom \
--network vpc-demo --allow tcp:0-65535,udp:0-65535,icmp --source-ranges 10.0.0.0/8
 
# 4 - VM instance
gcloud compute instances create vpc-demo-instance1 \
--zone us-east1-d --subnet vpc-demo-subnet1
 
# 5 - HA VPN gateway
gcloud compute vpn-gateways create vpc-demo-vpn-gw1 --network vpc-demo --region us-east1
 
# 6 - Cloud Router
gcloud compute routers create vpc-demo-router1 --network vpc-demo --region us-east1 --asn 65001
 
# 7 - VPN tunnel (repeat with --interface 1 for the second tunnel)
gcloud compute vpn-tunnels create vpc-demo-tunnel0 \
--peer-gcp-gateway on-prem-vpn-gw1 --region us-east1 --ike-version 2 \
--shared-secret SECRET --router vpc-demo-router1 \
--vpn-gateway vpc-demo-vpn-gw1 --interface 0
 
# 8 - Router interface for that tunnel (link-local IP)
gcloud compute routers add-interface vpc-demo-router1 \
--interface-name if-tunnel0-to-on-prem --ip-address 169.254.0.1 \
--mask-length 30 --vpn-tunnel vpc-demo-tunnel0 --region us-east1
 
# 9 - BGP peer on that interface (peer's ASN)
gcloud compute routers add-bgp-peer vpc-demo-router1 \
--peer-name bgp-on-prem-tunnel0 --interface if-tunnel0-to-on-prem \
--peer-ip-address 169.254.0.2 --peer-asn 65002 --region us-east1

Cloud Router and dynamic routing

Cloud Router with a BGP session over a VPN tunnel: Google Cloud subnets (Test/Prod/Staging) and a peer network with rack subnets exchange routes dynamically over link-local IPs.
Cloud Router runs BGP over the VPN tunnel, so new subnets on either side are advertised automatically without touching the tunnel. The BGP session uses an extra link-local IP (169.254.0.0/16) on each end - addresses that belong to neither network.

Cloud Router manages a VPN tunnel's routes with BGP, so routes are updated and exchanged without changing the tunnel configuration. When you add a new subnet on either side (for example a new Staging subnet in Google Cloud, or a new 10.0.30.0/24 subnet on-premises), it is advertised automatically and instances can send/receive traffic immediately. The peer gateway must support BGP.

GotchaBGP uses link-local IPs from 169.254.0.0/16

To set up BGP, each end of the tunnel gets an extra link-local IP from 169.254.0.0/16. These addresses belong to neither network and exist solely to establish the BGP session.

Recap

DECISIONClassic VPN or HA VPN?
Classic VPNHA VPN
SLA99.9%99.99% (two/four tunnels)
InterfacesOneTwo (two auto-assigned external IPs)
RoutingStatic or dynamic (BGP)Dynamic (BGP) only
RedundancySingle tunnel per gatewayTwo-tunnel / multi-topology
StatusLegacy (pre-HA gateways)Recommended for new deployments
Pick this when: Use HA VPN for anything new (99.99% SLA, BGP-only); Classic VPN only remains for legacy gateways predating HA VPN