VPC & Networking

💤0
Lv 10 XP
← 🌐 Google Cloud · Core Services

VPC & Networking

Intermediate ⭐ 80 XP ⏱ 18 min #gcp#vpc#networking

Build networks on GCP with global VPCs, subnets, firewall rules, and load balancing.

📖Theory

A distinctive GCP feature: VPCs are global, not regional. One VPC spans all regions, and its subnets are regional. This simplifies multi-region architectures compared to clouds where you peer per-region networks.

Core pieces:

  • VPC + subnets — global network, regional subnets (each a CIDR range)
  • Firewall rules — VPC-level, stateful, allow/deny by tags/service accounts
  • Cloud Router + Cloud NAT — outbound internet for private instances
  • Cloud Load Balancing — including a global HTTP(S) load balancer with one anycast IP worldwide
🌍Real-World Example
gcloud compute networks create app-vpc --subnet-mode=custom
gcloud compute networks subnets create web \
  --network=app-vpc --region=europe-west1 --range=10.0.1.0/24

# Allow HTTPS to instances tagged "web"
gcloud compute firewall-rules create allow-https \
  --network=app-vpc --allow=tcp:443 --target-tags=web
✍️Hands-On Exercise
  1. Explain why a GCP VPC being global simplifies multi-region design.
  2. Create a custom-mode VPC with one regional subnet.
  3. Write a firewall rule (in words) allowing HTTPS only to web-tagged instances.
  4. Describe what Cloud NAT provides for private instances.
🧾Cheat Sheet
ComponentDetail
VPCGlobal network
SubnetRegional CIDR range
Firewall rulesVPC-level, stateful, tag-based
Cloud NATOutbound for private VMs
Cloud Load BalancingIncl. global HTTP(S) LB
Network tagsTarget for firewall rules
💬Common Interview Questions
How is a GCP VPC different from AWS/Azure networks?

GCP VPCs are global — a single VPC spans all regions, with regional subnets — whereas AWS/Azure networks are regional and must be peered across regions.

How do GCP firewall rules typically target workloads?

By network tags or service accounts rather than just IP ranges, so the policy follows the workload’s identity regardless of its address.

📚Official Documentation

📝 My notes on this topic

Auto-saves as you type