Insights

GCP Peered VPC Can't Reach On-Prem via the Hub's VPN? Check Custom Route Export

November 19, 2026
0:00
Your spoke VPC is peered to a hub VPC. Instances in the spoke can ping resources in the hub's subnets without trouble. But when they try to reach an on-prem network sitting behind the hub's Cloud VPN tunnel or Interconnect attachment, packets vanish. No route, no response, nothing in logs. The peering is active, firewall rules look correct, and the VPN tunnel itself is healthy. The problem is almost always a single checkbox: custom route export on the peering connection.
When two VPC networks establish a peering relationship in GCP, the control plane does something specific: it automatically exchanges subnet routes between the two networks. Subnet routes are the routes that correspond to each VPC's configured subnets. If the hub VPC has a subnet 10.0.1.0/24 in us-central1, the spoke VPC automatically gets a route pointing to that CIDR through the peering connection. This happens without any extra configuration. But subnet routes are not the only routes in a VPC's routing table. There are also custom routes, which fall into two categories:
  • Static routes — routes you manually created, like a static route pointing 192.168.0.0/16 to a next-hop VPN tunnel.
  • Dynamic routes — routes learned via Cloud Router's BGP sessions, typically from a Cloud VPN tunnel or a Dedicated/Partner Interconnect VLAN attachment. When your on-prem router advertises 172.16.0.0/12 over BGP, Cloud Router installs that as a dynamic route in the hub VPC.
Here is the critical behavior: by default, GCP VPC peering does NOT exchange custom routes. Only subnet routes cross the peering boundary automatically. Your on-prem prefixes, learned via BGP or configured as static routes in the hub, stay invisible to the spoke VPC unless you explicitly tell the peering to export and import them.
Walk through the packet path from a spoke VM trying to reach an on-prem host at 172.16.10.5.
  1. The VM in the spoke VPC constructs a packet with destination 172.16.10.5 and hands it to the VPC networking stack.
  2. GCP's software-defined networking layer looks up the effective routes for that VM's VPC network.
  3. It finds subnet routes for the spoke's own subnets, subnet routes imported from the hub via peering, and possibly a default internet gateway route (0.0.0.0/0). But no route matching 172.16.10.0/24 or any parent prefix covering 172.16.10.5.
  4. Without a matching route, the packet either hits the default route (and gets sent toward the internet gateway, where it will be dropped because 172.16.10.5 is an RFC 1918 address) or gets dropped outright if there is no default route.
The hub VPC has the route. Cloud Router learned it via BGP from the on-prem side. The VPN tunnel is up. But the spoke VPC never received that route because the peering connection was not configured to share custom routes.
Two things to inspect: the effective routes visible to a VM in the spoke VPC, and the peering configuration on both sides. To see effective routes for a specific VM instance:
BASH
gcloud compute routes list --filter='network=spoke-vpc'
Look for any route with a destination range matching your on-prem CIDR (e.g., 172.16.0.0/12 or whatever your on-prem router advertises). If it is missing, the spoke VPC has no path to on-prem. To check the peering configuration:
BASH
gcloud compute networks peerings list --network=hub-vpc
Sample output format:
TEXT
NAME              NETWORK   PEER_PROJECT   PEER_NETWORK   IMPORT_CUSTOM_ROUTES   EXPORT_CUSTOM_ROUTES   STATE   STATE_DETAILS
hub-to-spoke      hub-vpc   spoke-proj     spoke-vpc      False                  False                  ACTIVE  [2025-01-15T...]
The columns IMPORT_CUSTOM_ROUTES and EXPORT_CUSTOM_ROUTES tell the whole story. If EXPORT_CUSTOM_ROUTES is False on the hub side, the hub is not sharing its custom routes (including the on-prem dynamic routes) with the spoke. If IMPORT_CUSTOM_ROUTES is False on the spoke side, the spoke would not accept them even if offered. Both sides need the correct setting. The hub must export custom routes, and the spoke must import them.
Update the peering on the hub VPC to export custom routes:
BASH
gcloud compute networks peerings update hub-to-spoke \
  --network=hub-vpc \
  --export-custom-routes
Update the peering on the spoke VPC to import custom routes:
BASH
gcloud compute networks peerings update spoke-to-hub \
  --network=spoke-vpc \
  --import-custom-routes
After both commands complete, GCP's control plane propagates the hub's custom routes (static and dynamic) into the spoke VPC's routing table. Within a short time (typically seconds to a couple of minutes), the spoke VM's effective routes should include the on-prem prefixes. Run the routes list command again to confirm the on-prem CIDR now appears with a next hop type like NEXT_HOP_VPN_TUNNEL or NEXT_HOP_INTERCONNECT_ATTACHMENT, routed through the peering.
This default is intentional. VPC peering in GCP is non-transitive by design. If VPC-A peers with VPC-B, and VPC-B peers with VPC-C, VPC-A cannot reach VPC-C through VPC-B. Exporting custom routes loosens this boundary in one specific direction: it lets a peered VPC see routes that the other VPC learned from somewhere else (VPN, Interconnect, static config). But it does not make peering fully transitive. A spoke VPC that imports the hub's on-prem routes can reach on-prem, but a third VPC peered only to the spoke still cannot reach on-prem through the spoke. This matters for hub-and-spoke architectures. Each spoke must peer directly with the hub, and each spoke's peering must have custom route import enabled. There is no route "cascading" through multiple peering hops. Another reason for the default: route conflicts. If the hub exports a 0.0.0.0/0 default route pointing at an on-prem firewall, and the spoke also has its own 0.0.0.0/0 pointing at the internet gateway, importing that route creates ambiguity. GCP resolves this with route priority, but it can cause unexpected traffic paths if you are not paying attention. Keeping custom route exchange off by default forces you to opt in deliberately.
Getting the route into the spoke VPC is necessary but not sufficient. GCP firewall rules are per-VPC-network. Even after the spoke can route packets toward on-prem via the hub's VPN tunnel, the hub VPC's firewall rules must allow that traffic to transit. Specifically:
  • The hub VPC needs an ingress firewall rule allowing traffic from the spoke's subnet ranges, destined for the VPN tunnel or Interconnect next hop.
  • The on-prem firewall needs to allow traffic from the spoke's IP ranges.
  • Return traffic from on-prem must also have a route back. If the hub's Cloud Router advertises only the hub's subnets to on-prem, on-prem won't know how to reach the spoke's subnets. You need to configure Cloud Router to also advertise the spoke's subnet ranges to on-prem, either through custom route advertisements on the Cloud Router or by configuring the on-prem router with static routes.
This return-path problem is a common second failure after fixing the custom route export. Traffic flows spoke-to-on-prem, but responses from on-prem never come back because the on-prem router has no route to the spoke's CIDR.
One subtle behavior: when you enable custom route export, GCP exports all custom routes from that VPC, not a filtered subset. If the hub has static routes you did not intend to share (like a blackhole route for testing, or a route pointing to an internal appliance), those also land in the spoke's routing table. There is no per-route export filter on the peering itself. You control what gets exported by controlling what custom routes exist in the hub VPC. Dynamic routes learned via Cloud Router follow the hub VPC's dynamic routing mode. If the hub is set to global dynamic routing mode, Cloud Router's learned routes apply to all regions. If set to regional, they apply only to the region where the Cloud Router sits. This regional scoping also affects what the spoke sees after import: if the spoke has VMs in a different region than the hub's Cloud Router, and the hub uses regional routing mode, those VMs may still not see the on-prem routes even after enabling custom route exchange.
When a spoke VPC cannot reach on-prem through the hub's VPN or Interconnect:
  1. Confirm the VPN tunnel or Interconnect attachment is up and Cloud Router has learned the on-prem prefixes. Check gcloud compute routers get-status ROUTER_NAME --region=REGION on the hub side.
  2. Check the peering config on both sides for EXPORT_CUSTOM_ROUTES (hub) and IMPORT_CUSTOM_ROUTES (spoke).
  3. After enabling export/import, verify the on-prem route appears in the spoke's route list.
  4. Check firewall rules on the hub VPC allow transit from spoke CIDRs.
  5. Verify the on-prem router has return routes to the spoke's subnets, not just the hub's.
  6. If using regional dynamic routing mode on the hub, confirm the spoke VMs are in the same region as the Cloud Router, or switch to global mode.
Most of the time, step 2 is the fix. The rest are the follow-up issues that surface once packets actually start flowing.

Join My Newsletter & Get Updates!

Get notified whenever a new technical guide, server infrastructure breakdown, or personal reflection goes live, plus a curated weekly digest.