Global VPC, Subnets, Firewall Rules & Shared VPC Architecture

Understand GCP's unique global VPC network design, regional subnets, firewall rule targeting via Network Tags, and enterprise Shared VPC topologies.

intermediate 25 min lesson hands-on task included

GCP Virtual Private Clouds (VPC) differ fundamentally from AWS VPCs. While an AWS VPC is bound to a single AWS Region, a GCP VPC is a GLOBAL resource.

A single GCP VPC can contain subnets in every Google Cloud region around the world, connected across Google’s private global fiber backbone without needing inter-region VPC peering or transit gateways.


Topic 1: Custom Mode vs. Auto Mode VPCs

SHARED VPC TOPOLOGY — CENTRALIZED NETWORK & DECENTRALIZED COMPUTE HOST PROJECT (net-host-prod) Central Network Admin GLOBAL VPC NETWORK (prod-vpc) Subnet us-central1 (10.1.0.0/20) Shared to Service Project A (web-prod) Firewall Tag: target-web-servers Subnet europe-west1 (10.2.0.0/20) Shared to Service Project B (data-prod) Firewall Tag: target-db-instances SERVICE PROJECT A (web-prod) • Binds GCE & GKE instances to Subnet us-central1 • Developers manage compute, NOT VPC routing IAM Role: compute.networkUser on Host Subnet SERVICE PROJECT B (data-prod) • Binds Cloud SQL & Memorystore to Subnet europe-west1 • Private Service Connect & Peering integration Isolated IAM scope per workload team VPC PEERING VS SHARED VPC: Shared VPC is for projects inside ONE Org. VPC Peering connects independent VPCs across Orgs without transitivity.
GCP Shared VPC topology: Centralized Host Project manages VPC subnets, routes, and firewall rules; Service Projects attach application workloads into host subnets.

When creating a VPC network in GCP, you choose between two modes:

  1. Auto Mode VPC (Non-Production / Sandbox):

    • Automatically creates one subnet in every GCP region using predefined CIDR ranges (10.128.0.0/20, 10.132.0.0/20, etc.).
    • Default firewall rules are auto-created.
    • Production Risk: CIDR ranges overlap with other standard networks, making VPN or hybrid interconnect impossible.
  2. Custom Mode VPC (Enterprise Production Standard):

    • No subnets are created automatically.
    • Network engineers explicitly define subnets, regions, and non-overlapping CIDR blocks.
    • Required for Shared VPCs, VPNs, and Dedicated Interconnects.
# Create an enterprise Custom Mode Global VPC
gcloud compute networks create prod-vpc \
  --subnet-mode=custom \
  --bgp-routing-mode=global

# Add a regional subnet in us-central1 with a primary range and secondary pod ranges
gcloud compute networks subnets create prod-subnet-us-central1 \
  --network=prod-vpc \
  --region=us-central1 \
  --range=10.100.0.0/20 \
  --secondary-range=gke-pods=10.200.0.0/14,gke-services=10.204.0.0/20

Topic 2: VPC Firewall Rules & Network Tag Targeting

GCP VPC firewalls are global, stateful inspection filters.

  • Default State: Ingress is denied by default; Egress is allowed by default.
  • Stateful Behavior: If ingress traffic is allowed, return egress response traffic is automatically allowed regardless of egress rules.
  • Rule Priorities: Evaluated numerically from 0 (highest priority) to 65535 (lowest priority default rules).

Targeting Firewall Rules: Instead of attaching security groups to network interfaces, GCP applies firewall rules to VM instances using:

  1. Network Tags (e.g., target-web-server)
  2. Service Accounts (e.g., sa-frontend@project.iam.gserviceaccount.com — more secure than tags because tags can be edited by anyone with Compute Instance Admin permissions).
# Ingress rule targeting VMs with network tag 'target-web-server'
gcloud compute firewall-rules create allow-http-web-tags \
  --network=prod-vpc \
  --direction=INGRESS \
  --priority=1000 \
  --action=ALLOW \
  --rules=tcp:80,tcp:443 \
  --source-ranges=0.0.0.0/0 \
  --target-tags=target-web-server

Topic 3: Shared VPC Architecture (Host vs. Service Projects)

In large organizations, placing compute workloads and networking into a single shared GCP project causes operational chaos. GCP solves this with Shared VPC:

  • Host Project: A central project owned by the Network/SecOps team that contains the Shared VPC network, subnets, VPN gateways, Cloud Routers, and central firewall rules.
  • Service Projects: Application projects owned by service teams (e.g., checkout-service, analytics-service) attached to the Host Project.
  • Mechanism: The Host Project admin grants the roles/compute.networkUser role on specific subnets to the Service Project service accounts. Developers in Service Projects can launch GCE VMs or GKE nodes attached to the Host subnets, but cannot edit subnets, routes, or firewall rules.

Topic 4: Connecting Networks: Shared VPC vs. VPC Peering vs. Cloud Interconnect

Connectivity OptionUse CaseCross-Organization?Transitive Routing?
Shared VPCCentralized networking within ONE GCP OrganizationNo (Same Org only)N/A (Single VPC)
VPC Network PeeringConnect distinct VPC networks privately (low latency)YesNo (Non-transitive: Network A ↔ B and B ↔ C does NOT allow A ↔ C)
Cloud VPNEncrypted IPsec tunnels over public internet (less than 3 Gbps/tunnel)Yes (On-prem to GCP)Supported via Cloud Router BGP
Dedicated InterconnectDirect physical fiber connection to GCP PoP (10G–200G)Yes (On-prem to GCP)Supported via Cloud Router BGP

Common mistake: Building on the auto-mode default VPC because it is already there. It creates a subnet in every region with predictable ranges and permissive default firewall rules, which is both a security surface and a guarantee of a CIDR collision the first time you peer with anything. Create a custom-mode VPC and allocate ranges deliberately.