Skip to content
Operate

HA VPN with BGP

Add an HA VPN gateway with Cloud Router BGP so the Tunnels page can build HA VPN tunnels for healthcare organizations whose firewalls support BGP.

On this page

The GKE install has a Classic VPN gateway. The engine creates a tunnel and its static routes on it when you add a connection on the Tunnels page. That works with almost every firewall, including policy-based ones without BGP.

When a healthcare organization's firewall supports BGP and the connection needs Google's 99.99% availability SLA, turn on HA VPN. Terraform adds an HA VPN gateway with two interfaces and its own Cloud Router, and tells the engine about them. The Tunnels page then offers HA VPN: for each connection the engine creates two tunnels and two BGP sessions. BGP moves traffic to the other tunnel when one goes down, so there is no route priority to swap. The engine's tunnel watcher still watches both tunnels: it reports one interface down as degraded, and re-creates the connection when both tunnels stay down. See Self-healing watcher.

flowchart LR
    subgraph YOURS["Your Google Cloud project"]
        direction TB
        CR["Cloud Router\nadvertises the node subnet only\nimports only allowed prefixes"]
        HA["HA VPN gateway\ninterface 0 and 1"]
        ENG["Engine and MLLP listener"]
        CR --- HA
        HA --> ENG
    end
    P["Healthcare organization\nVPN device(s)"]
    P == "tunnel 0, BGP" ==> HA
    P == "tunnel 1, BGP" ==> HA

What changes and what does not

PartClassic VPN (default)HA VPN (optional)
Who creates tunnelsThe engine, from the Tunnels pageThe engine, from the Tunnels page (or ha_vpn_peers)
RoutingStatic routes per remote subnetBGP, limited to the remote subnets you enter
FailoverOptional backup tunnel and a watcherBuilt in: two tunnels, two BGP sessions; the watcher re-creates a connection whose tunnels both stay down
Range the healthcare organization seesThe node subnetThe node subnet (the only advertised range)
Peer requirementsIKEv1 or IKEv2, policy or route basedIKEv2 and BGP
AlertMedHook VPN tunnel is downMedHook VPN tunnel is down, per interface; a BGP session alert for ha_vpn_peers

Turning HA VPN on does not change the Classic gateway, its IP or any tunnel the engine created. You can run both: Classic tunnels for organizations without BGP, HA VPN for the ones with it.

Which routes are accepted

A BGP peer can announce any prefix: the default route 0.0.0.0/0, or a range that belongs to another healthcare organization. Without a filter, the Cloud Router would install those routes and send the engine's traffic, including PHI bound for other organizations, into that peer's tunnel.

So every HA VPN connection has an import policy on the Cloud Router. It accepts only the connection's remote subnets (and anything more specific inside them) and drops everything else. The remote subnets are required for HA VPN, the same as for Classic VPN, and:

  • each must be an IPv4 network from /8 to /32, so the default route and very large ranges are refused;
  • they must not overlap another tunnel's remote subnets, in any workspace;
  • the reverse holds too: a Classic VPN tunnel, or an imported or onboarded one, is refused if its remote subnets overlap an HA VPN connection's remote subnets, in any workspace, on create and on every edit, so a BGP peer can never announce a more specific route that pulls another healthcare organization's traffic into its tunnel. Classic tunnels may not overlap each other either: two static routes for overlapping ranges would send one organization's traffic down the other's tunnel. A backup tunnel is the one exception, since it routes its primary's subnets by design (see Remote subnets must not overlap);
  • for ha_vpn_peers, they must not overlap the node subnet or another peer's (the plan stops).

If an organization adds a range later, edit the tunnel's remote subnets. The engine rebuilds the tunnel with the new policy; the peer sees a short outage while IKE and BGP come back up.

What the engine is allowed to do

With HA VPN on, the engine's service account gets one more custom role. It holds exactly what the HA tunnel code calls: create, read, use and delete external VPN gateways (the peer side), read and use the HA gateway, and read, use and update Cloud Routers (interfaces, BGP sessions and route policies). Tunnel and operation rights come from the Classic VPN role it already has. Google Cloud IAM Conditions cannot narrow these permissions to one router or gateway, so the grant is project-level, like the Classic role. With HA VPN off, the role is not created.

Steps

1. Turn it on

In terraform.tfvars:

hcl
ha_vpn_enabled    = true
ha_vpn_router_asn = 64514 # private ASN for your side

Apply and redeploy so the engine picks up the new settings:

bash
cd terraform/gke
terraform apply
terraform output ha_vpn_gateway_ips

The Helm values now carry GCP_HA_VPN_GATEWAY, GCP_HA_VPN_GATEWAY_IPS, GCP_CLOUD_ROUTER and GCP_CLOUD_ROUTER_ASN. Until they are set, the Tunnels page says HA VPN needs the HA gateway and Cloud Router.

2. Agree the peer settings

For each healthcare organization, agree with its network team:

  • the public IP of its VPN device, or two IPs for two devices
  • its BGP ASN
  • the ranges it will announce (its remote subnets)
  • two link-local /30 ranges inside 169.254.0.0/16, one per tunnel. The Tunnels page suggests free ones.

3. Create the tunnel

On Tunnels > New tunnel, choose HA VPN and fill in the peer IPs, peer ASN, BGP ranges and remote subnets. The page shows the peer configuration for common firewalls. Send the pre-shared key over a channel you would use for a password, never in a ticket.

4. Check the sessions

The tunnel's page shows the state of both BGP sessions and the routes learned from the peer. From the command line:

bash
gcloud compute routers get-status "$(terraform output -raw ha_vpn_router)" \
  --region="$REGION" --format="yaml(result.bgpPeerStatus[].name,result.bgpPeerStatus[].status)"

Both sessions per connection should be UP. A route the peer announces outside its remote subnets does not appear among the learned routes.

If a session stays down, compare the peer's ASN and its two link-local addresses with what you entered, and check the tunnel itself is established: BGP cannot come up over a tunnel that is down. If the sessions are up but traffic does not flow, check that the peer announces its remote subnets exactly, or ranges inside them: anything else is dropped by the import policy.

Peers managed by Terraform (optional)

If you would rather keep some connections in Terraform than on the Tunnels page, list them in ha_vpn_peers. Each one gets the same two tunnels, two BGP sessions and import policy, on the same gateway and router, plus a per-session alert when alerting is on.

hcl
ha_vpn_peers = [
  {
    name             = "demo-health"
    peer_asn         = 65010
    peer_ips         = ["203.0.113.10", "203.0.113.11"]
    bgp_ranges       = ["169.254.10.0/30", "169.254.10.4/30"]
    allowed_prefixes = ["10.60.0.0/16"] # the only routes accepted from this peer
  },
]

With one peer IP, both tunnels end on the same device. With two, each tunnel goes to its own device. The plan stops if peers are listed while ha_vpn_enabled is off, or if allowed_prefixes is empty, contains a default route, or overlaps another peer's or the node subnet. These connections do not appear on the Tunnels page, so pick BGP ranges and allowed prefixes that the page's tunnels do not use. Their settings, including the shared secrets, are in the sensitive output terraform output -json ha_vpn_peer_config.

Checklist

  • ha_vpn_enabled is applied and the engine was deployed again, so the Tunnels page offers HA VPN.
  • Each connection's remote subnets are agreed with the healthcare organization and overlap no other tunnel's.
  • Both BGP sessions of every connection are UP.
  • The MedHook VPN tunnel is down alert policy reaches someone, and a test notification arrived.

Reference

VariableDefaultWhat it sets
ha_vpn_enabledfalseCreates the HA VPN gateway, its Cloud Router and the engine's HA role, and sets the env.
ha_vpn_router_asn64514Private ASN of the Cloud Router.
ha_vpn_peers[]Terraform-managed peers: name, peer_asn, peer_ips, bgp_ranges, allowed_prefixes.