Hybrid networking
The VPN tunnel is up, but nothing gets through
I connected a client’s GCP project to our AWS VPCs so our reporting stack could reach their private Cloud SQL database. Both consoles showed the tunnels as up. Connections hung anyway, for six different reasons across two builds.
- Stack
- GCP Classic Cloud VPN, AWS Virtual Private Gateway, IPsec, Cloud SQL private IP, GKE, Redshift
- My role
- Design, pre-flight checks, debugging and the runbook
- Outcome
- Links to two AWS regions are in production. The next one is a checklist instead of a debugging session.
Why a VPN
The client’s data had to stay on private IPs inside their GCP project. Our BI and reporting tools run in AWS, in two regions. A static-route IPsec VPN between GCP Classic VPN and an AWS Virtual Private Gateway was the simplest option that met the requirement.
A tunnel that’s up proves very little
The IPsec status only tells you the two gateways agreed on keys. Every packet still needs a route out and a route back, on both sides. If any one entry is missing, the symptom is the same: the connection hangs, with no error anywhere.
The routing matrix
Most of the job is making this table complete, in both directions:
| Where | What has to be there |
|---|---|
| The AWS VPN connection’s own route list | Every GCP range: the VPC subnets, the GKE pod range and the Cloud SQL private services range |
| AWS route tables, including the main table | The same GCP ranges, pointing at the virtual private gateway |
| GCP static routes, one per tunnel | The full AWS VPC range |
| The GCP private services peering | Custom route export turned on |
| GCP firewall and AWS security groups | Only the ports that are actually needed |
Six reasons it hung
| What we saw | What was actually wrong |
|---|---|
| AWS to Cloud SQL hangs, but GCE VMs answer | Cloud SQL lives in a peered network that Google manages. Without custom route export on that peering, its replies have no route back to AWS. |
| Every AWS to GCP connection hangs | GCP only had routes for the /30 tunnel link addresses, not the AWS VPC range, so replies had no way back. |
| VMs reach AWS, but GKE pods time out | VPC-native GKE doesn’t translate pod addresses when the destination is a private range. Packets left with the pod range as their source, and AWS had no route for it. |
| The route was added to AWS route tables, but traffic still doesn’t flow | A static-route VPN connection keeps its own route list. Route tables alone aren’t enough. |
| Redshift is “unreachable” | The test used port 5432. Redshift listens on 5439. |
| Some AWS IPs are unreachable even with the full-VPC route | A peering with a managed database provider had added more specific /27 routes inside the AWS range. The most specific route wins. |
How I debug a hang now
A hang means a dropped packet or a missing return route. “Connection refused” means you reached the host. I check things in this order:
- Tunnel status on both sides.
- The AWS VPN connection’s route list.
- The route table of the subnet the traffic starts from (or the main table).
- GCP routes toward the AWS range.
- Private services route export, for Cloud SQL only.
- The source address actually used: pod or node.
- Firewall rules, security groups and the port.
Then I always finish with a live test from the real source, such as a pod, not a laptop:
nc -zv -w 5 <private-ip> <port>
Before building the next one
Pre-flight reads now check new address ranges for overlap with every other client already on the same gateway, and against every other peering’s routes. All of this happens before anything is created. Every change goes out as a written plan, with the exact command and a rollback for each side.
What I’d do differently
Use HA VPN with BGP instead of Classic VPN with static routes. With BGP, each side advertises its own ranges, including GKE’s pod range, so most of the routing gaps above can’t happen through a missed entry. Cloud SQL’s range still needs a custom advertisement on Cloud Router, and HA VPN also brings a 99.99% availability SLA.
What I took from it
- “Up” is a statement about keys, not about packets.
- Check the route back before the route there. Most of these failures were on the return path.
- Find out which source address the packet really uses. Containers often aren’t who you think they are.