Three ways to reach GCP from an office
Builds on6. Kadé's office network29. Tunnels
| # | Option | How | Fits | Kadé |
|---|---|---|---|---|
| 1 | Per person, over the internet | IAP for SSH and admin tools (chapter 6), IAP for HTTPS or Cloudflare Access for web apps (chapter 13) | People with Google identities, occasional admin work | Kept for admin access |
| 2 | Site-to-site VPN | An encrypted tunnel between the office router and GCP, over the internet. Whole networks talk on private IPs | Devices that cannot sign in, steady office-to-cloud traffic, modest bandwidth | Kadé's choice |
| 3 | Interconnect | A private physical link, or a link through a provider, into Google's network | Many gigabits, predictable latency, large data volumes | Not needed (section 08) |
The hybrid family
| # | Product | Path | Bandwidth | Availability SLA | Encrypted |
|---|---|---|---|---|---|
| 1 | HA VPN | IPsec over the internet | About 3 Gbps per tunnel; add tunnels for more | 99.99% with two tunnels, one from each gateway interface | Yes (IPsec) |
| 2 | Classic VPN | IPsec over the internet, one interface | Same per tunnel | 99.9% | Yes |
| 3 | Dedicated Interconnect | Your own 10 or 100 Gbps fibre to a Google colocation facility | 10-200+ Gbps | 99.9% or 99.99% with redundant links | No by default; MACsec or HA VPN over it |
| 4 | Partner Interconnect | Through a service provider already connected to Google | 50 Mbps to 50 Gbps | 99.9% or 99.99% | No by default |
| 5 | Cross-Cloud Interconnect | Google-managed link to another cloud (AWS, Azure…) | 10 or 100 Gbps | 99.9% or 99.99% | No by default |
HA VPN: the parts
An HA VPN connection is five GCP resources plus the office router. Click each part to see what it holds and Kadé's value:
HA VPN gateway · kade-havpn
- Kadé's value
- asia-southeast1 · interface 0: 34.124.x.1 · interface 1: 34.124.x.2 (Google-assigned)
Holds: A regional GCP resource with two interfaces, each with its own public IP that Google assigns. It is the GCP end of every tunnel.
Cloud Router and BGP: who learns which routes
Builds on12. Routing and BGP
HA VPN uses dynamic routing: the Cloud Router and the office router run BGP over each tunnel, and each tells the other which ranges it can reach (chapter 4: dynamic routes). Nothing is typed in by hand, and when a tunnel fails its routes disappear by themselves. The important question is what each side advertises, because a range that is not advertised simply has no path.
Office reaches subnets, Cloud SQL, and DNS replies come back
Kadé advertises its subnets plus two ranges that are not subnets: Cloud SQL's 10.10.32.0/20 and Cloud DNS's 35.199.192.0/19. The office advertises its whole 172.16.0.0/16. Each side installs the other's list as routes through the tunnels.
Show as config
kade-vpn-router: advertisement-mode CUSTOM groups: ALL_SUBNETS ranges: 10.10.32.0/20, 35.199.192.0/19 office router: advertises 172.16.0.0/16
| # | Kadé advertises | Why | Learned from |
|---|---|---|---|
| 1 | All subnets of kade-vpc (default) | Office reaches kade-worker and anything else in a subnet | Automatic |
| 2 | 10.10.32.0/20 | Cloud SQL's private services range is not a subnet of kade-vpc, so it is not advertised by default | Chapter 9 |
| 3 | 35.199.192.0/19 | Replies to Cloud DNS forwarding queries (chapter 8) must find their way back over the VPN | Chapter 8 |
Two tunnels: sharing load and failing over
With two tunnels, there are two ways to use them. BGP decides, through the priority Cloud Router attaches to the routes it advertises and the priority the office router uses:
kade-vpc's routes to 172.16.0.0/16
- 172.16.0.0/16 via tunnel 0priority 100ECMP
- 172.16.0.0/16 via tunnel 1priority 100ECMP
Both tunnels advertise the office route with the same priority, so kade-vpc has two equal routes and shares connections across them (ECMP, chapter 4 example D). Uses both tunnels' bandwidth.
Show as config
office-0: advertised-route-priority 100 office-1: advertised-route-priority 100 → two equal routes to 172.16.0.0/16 (ECMP)
| # | Setting | Default | Effect |
|---|---|---|---|
| 1 | BGP keepalive and hold time | 20 s keepalive | Without BFD, a silent tunnel failure is noticed after up to about a minute |
| 2 | BFD (Bidirectional Forwarding Detection) | off | Detects a dead path in about a second, if the office router supports it |
| 3 | Advertised route priority (base priority) | 100 | Lower wins, the same idea as route priority in chapter 4. Give one tunnel a higher number to make it the backup |
MTU over the tunnel
Builds on18. MTU, MSS and fragmentation
IPsec wraps each packet in extra headers before it crosses the internet. The inside packet must therefore be smaller than the outside path allows. Chapter 1.2 promised this would come back:
Cloud VPN handles the outer packet size on Google's side. On the office side, MSS clamping keeps TCP from filling the tunnel with packets that will not fit once wrapped. Header sizes vary with the cipher; these are typical.
| # | Rule | Why |
|---|---|---|
| 1 | Cloud VPN carries inner packets up to 1460 bytes | The same as kade-vpc's default MTU (chapter 1.2), so VMs and the tunnel agree |
| 2 | Set the office side of the tunnel to the same size, and clamp TCP MSS on the office router | Office PCs think in 1500-byte packets. Clamping MSS (Google's peer guides suggest values around 1360 to 1420) makes TCP pick smaller segments from the start |
| 3 | If kade-vpc's MTU is ever raised to 1500 or 8896, the VPN does not follow | Large packets to the office would no longer fit through the tunnel |
| 4 | The symptom of getting it wrong | Small things work (ping, DNS, logins); large transfers or big pages hang. The fundamentals course' "black hole" again |
Everything the VPN touches
A tunnel that is up only means packets can travel. Each real flow also needs a route on both sides, a firewall rule, and often DNS. These are Kadé's three flows; switch one piece off to see which flow breaks:
What this flow needs
- route office → 10.10.1.0/24Cloud Router advertises all subnets
- route kade-vpc → 172.16.0.0/16learned over BGP
- firewall on kade-workerkade-warehouse-to-inventory · tcp:8443 from 172.16.2.0/24
Works
Route out: the office learned 10.10.1.0/24 over BGP. Route back: kade-vpc learned 172.16.0.0/16. Firewall: kade-warehouse-to-inventory allows tcp:8443 from 172.16.2.0/24 to sa-kade-worker. All three are needed.
Interconnect, briefly
Interconnect replaces "over the internet" with a private physical path into Google's network. The Cloud Router and BGP part stays exactly as above; the tunnel is replaced by a VLAN attachment on the physical link.
| # | Consider Interconnect when | Detail |
|---|---|---|
| 1 | You need more than a few Gbps steadily | Each VPN tunnel tops out around 3 Gbps |
| 2 | Latency must be steady | The internet path a VPN uses changes from hour to hour |
| 3 | You move a lot of data out of GCP | Egress over Interconnect is cheaper per GB than internet egress, which can pay for the port |
| 4 | Your site is near a Google colocation facility, or a partner serves it | Dedicated needs your equipment in the facility; Partner works through a provider that is already there |
Back to Kadé
Commands in this chapter
Commands 1 to 4 are read-only. Commands 5 to 7 change the project; the office router is configured separately, with the same secret, addresses and ASNs.
Are the tunnels up?
- What it shows: Each tunnel's status and the reason if it is not established.
- What to look for:
ESTABLISHEDon both. Other values usually mean a mismatched shared secret or IKE settings.
gcloud compute vpn-tunnels list --filter="region:asia-southeast1" \ --format="table(name,status,detailedStatus,peerIp)"Are the BGP sessions up, and what was learned?
- What it shows: Each BGP peer's state, and the routes learned from the office.
- What to look for: Both peers
Established, and172.16.0.0/16in the best routes.
gcloud compute routers get-status kade-vpn-router --region=asia-southeast1 \ --format="yaml(result.bgpPeerStatus,result.bestRoutes)"What does Kadé advertise to the office?
- What it shows: The Cloud Router's advertisement mode, groups and extra ranges.
- What to look for:
CUSTOM,ALL_SUBNETS, and both extra ranges.
gcloud compute routers describe kade-vpn-router --region=asia-southeast1 \ --format="yaml(bgp)"Test a full-size packet to the office
- What it shows: From kade-worker, whether 1460-byte packets cross the tunnel without fragmenting.
- What to look for: Replies at 1432 bytes of data. If small pings work and this one fails, it is MTU.
ping -c 3 -M do -s 1432 172.16.1.40Create the gateways (changes the project)
- What it shows: The HA VPN gateway, and a resource describing the office router.
- What to look for: The two public IPs GCP assigns to kade-havpn, which go into the office router's config.
gcloud compute vpn-gateways create kade-havpn --network=kade-vpc --region=asia-southeast1gcloud compute external-vpn-gateways create kade-office-gw --interfaces=0=198.51.100.20Create the router and one tunnel with its BGP session (changes the project)
- What it shows: The Cloud Router, tunnel 0, and its BGP session. Repeat the last three commands for interface 1 and 169.254.1.0/30.
- What to look for: Commands 1 and 2 report the tunnel and session up once the office side is configured.
gcloud compute routers create kade-vpn-router --network=kade-vpc \ --region=asia-southeast1 --asn=64512gcloud compute vpn-tunnels create kade-tunnel-0 --region=asia-southeast1 \ --vpn-gateway=kade-havpn --interface=0 \ --peer-external-gateway=kade-office-gw --peer-external-gateway-interface=0 \ --ike-version=2 --shared-secret=REPLACE-WITH-A-LONG-SECRET --router=kade-vpn-routergcloud compute routers add-interface kade-vpn-router --region=asia-southeast1 \ --interface-name=if-tunnel-0 --vpn-tunnel=kade-tunnel-0 --ip-address=169.254.0.1 --mask-length=30gcloud compute routers add-bgp-peer kade-vpn-router --region=asia-southeast1 \ --peer-name=office-0 --interface=if-tunnel-0 \ --peer-ip-address=169.254.0.2 --peer-asn=65010Advertise the extra ranges (changes the project)
- What it shows: Switches to custom advertisement: all subnets, plus Cloud SQL's range and Cloud DNS's forwarding range.
- What to look for: The office router's BGP table now lists both ranges via the tunnels.
gcloud compute routers update kade-vpn-router --region=asia-southeast1 \ --advertisement-mode=CUSTOM --set-advertisement-groups=ALL_SUBNETS \ --set-advertisement-ranges=10.10.32.0/20,35.199.192.0/19