← Back to Blog
GCP VPC Interview Questions & Answers
GCP12 questions·Nov 17, 2026

GCP VPC Interview Questions & Answers

This guide collects 12 real-world GCP interview questions with clear, interviewer-ready model answers, focused on VPC. Use it to revise quickly, spot gaps, and rehearse strong answers before your next interview.

1. What is the primary purpose of a VPC in GCP, and how does it differ from the default VPC that comes with a new project?

A VPC (Virtual Private Cloud) in GCP is a logically isolated network where you deploy and manage cloud resources with full control over IP address ranges, subnets, routes, and firewall rules. The default VPC is auto-created with predefined subnets in each region and a default firewall configuration allowing internal communication; a custom VPC requires explicit subnet and firewall configuration, giving you granular control but requiring more setup. The default VPC is convenient for quick prototyping but custom VPCs are recommended for production as they enforce least-privilege networking and prevent accidental resource exposure.

2. Explain the difference between auto-subnet and custom-subnet modes in GCP VPCs. When would you choose one over the other?

Auto-subnet mode automatically creates a subnet in each region with a fixed CIDR block (/20), making it simple but inflexible; custom-subnet mode requires you to manually define subnets with specific CIDR ranges, giving you full control over IP allocation and allowing non-overlapping subnets across regions. Choose auto-subnet for simple, multi-region deployments where default /20 ranges suffice and rapid iteration is prioritized. Choose custom-subnet for complex architectures, strict IP planning, multiple VPCs with peering, or when you need subnets smaller or larger than /20. Auto-subnet mode cannot be changed after VPC creation, so the initial choice is permanent.

3. A GKE cluster in subnet A (10.0.0.0/20) needs to communicate with a Cloud SQL instance in subnet B (10.1.0.0/20) within the same VPC. What networking configuration is required, and what might go wrong?

Both subnets are in the same VPC, so they can communicate by default as long as firewall rules permit—you must create an ingress firewall rule allowing traffic from subnet A's CIDR to the Cloud SQL instance's internal IP on port 3306 (or your database port). If the firewall rule is missing or uses the wrong source CIDR, the connection will timeout silently; if Cloud SQL is not configured with Private IP in that VPC, it will only be reachable via public IP, requiring a different security approach. Verify connectivity using gcloud compute ssh to a GKE node and then nslookup or nc against the Cloud SQL private IP to diagnose DNS or routing issues.

4. What is VPC peering in GCP, and how does it differ from using a shared VPC? Describe a scenario where you would use each.

VPC peering connects two separate VPCs by establishing a private, low-latency connection without routing traffic through the public internet; both VPCs must have non-overlapping CIDR ranges and peering must be created from both sides. Shared VPC uses a single host VPC managed by an organization, with multiple service projects attached, allowing centralized network administration and overlapping IP ranges across projects. Use VPC peering for connecting independent projects or organizations that need isolation but low-latency communication, such as partners or business units; use Shared VPC for organizations with multiple teams sharing infrastructure where a central networking team manages all routing and firewall policies. VPC peering is symmetric (traffic flows both ways equally), while Shared VPC has a clear hub-and-spoke topology.

5. Your organization has two VPCs: VPC-Prod (10.0.0.0/16) and VPC-Dev (10.1.0.0/16). You want to peer them, but later you realize you need to add another Dev environment in a third VPC with overlapping IP ranges (10.1.0.0/16). What are your options, and what are the trade-offs?

VPC peering requires non-overlapping CIDR ranges, so you cannot peer the third VPC directly; your options are: (1) re-IP the third VPC to a non-overlapping range like 10.2.0.0/16 and create new peering connections, which is disruptive if resources already exist; (2) use a Shared VPC model where VPC-Prod becomes the host and both Dev environments become service projects with allocated subnets, allowing overlapping ranges but requiring org-level restructuring; (3) use Cloud VPN or Cloud Interconnect to connect VPC-Dev and the third VPC privately, then peer that aggregated network to VPC-Prod, adding latency and cost. Re-IP is cleanest for greenfield setups; Shared VPC is best if you control the org structure; VPN is a workaround when IP ranges are locked in.

6. Describe the order in which GCP evaluates firewall rules and explain how the priority field affects rule matching.

GCP evaluates firewall rules in ascending order of priority: a rule with priority 100 is evaluated before priority 200. Within the same priority, GCP evaluates all rules; if multiple rules match a packet, the first matching rule (lowest priority number) determines whether traffic is allowed or denied. Deny rules take precedence regardless of priority if both allow and deny rules match at the same priority level. Best practice is to use priorities in increments of 10 or 100 to leave room for insertion (e.g., default deny at 65534, then specific allows at 100-1000, then catch-all allow at higher numbers), and to avoid using implicit denies by making deny rules explicit at lower priority. A common mistake is assuming a rule will take effect when a higher-priority rule already matched.

7. You have a firewall rule allowing HTTP traffic on port 80 from 0.0.0.0/0 to a Compute Engine VM with tag 'web-server'. The rule is applied to the VPC, but traffic from a specific external IP is still being blocked. What might be the cause?

The VM may not have the 'web-server' tag applied to it, so the rule does not match; verify tags using gcloud compute instances describe. Alternatively, a higher-priority deny rule may be blocking traffic before the allow rule is evaluated; review all deny rules with lower priority numbers. The VM may not have a public IP assigned, so inbound traffic from the internet does not reach it; cloud NAT or a load balancer may be needed. The VM may have a host-level firewall (iptables or ufw) blocking port 80; SSH into the VM and check netstat -tuln. Finally, the firewall rule might be implicitly created in the opposite direction—ensure there is also an egress rule allowing the response traffic back to 0.0.0.0/0 on port 80 (usually implicit but worth checking).

8. What is Cloud NAT in GCP, and how does it differ from using a NAT Gateway instance? When would you use each?

Cloud NAT is a fully managed service that allows VMs with only internal IPs to initiate outbound connections to the internet by translating their private IPs to the NAT gateway's public IP, with no manual configuration or gateway instances required. A NAT Gateway instance (a custom Compute Engine VM configured with iptables) requires you to manage the instance, monitor uptime, handle scaling, and troubleshoot networking manually. Use Cloud NAT for production workloads requiring high availability and minimal operational overhead; it automatically scales and is zone-redundant if deployed across multiple zones. Use a NAT Gateway instance only for highly specialized networking requirements not covered by Cloud NAT, such as custom packet inspection or non-standard protocols. Cloud NAT is significantly simpler and more reliable for typical use cases.

9. A Compute Engine VM in subnet 10.0.1.0/24 needs to reach a third-party API at 203.0.113.0/24. The firewall allows the outbound traffic, but the response traffic is not reaching the VM. What could be the issue, and how would you diagnose it?

The VM likely has a public IP and can initiate outbound traffic, but the return traffic is hitting a higher-priority firewall deny rule or the route back to the VM is not properly configured; verify using gcloud compute routes list to ensure the default route 0.0.0.0/0 exists and points to the internet gateway. If the VM uses only a private IP, Cloud NAT must be configured on the route to allow return traffic via NAT; check gcloud compute routers describe. Run gcloud compute ssh to the VM and use curl -v with tcpdump to capture packets and confirm the API is responding; confirm DNS resolution is working. Check the VM's OS-level firewall (iptables, Windows Firewall) to ensure it is not blocking inbound traffic on the response port. If the third-party API has geo-restrictions or blocks GCP IP ranges, contact the API provider.

10. Explain how routes work in a GCP VPC and describe the difference between a system-generated subnet route and a custom route.

Routes define how packets leaving a VM are forwarded to their destination based on the destination CIDR block and next-hop target (gateway, instance, or VPN tunnel). A system-generated subnet route is automatically created for each subnet and directs traffic destined for that subnet's CIDR block to be delivered locally within the VPC. A custom route is manually defined and typically points traffic destined for ranges outside the VPC to a next-hop like an internet gateway (0.0.0.0/0), a Cloud VPN tunnel, Cloud Interconnect, or another VM acting as a router. System routes have a lower priority (more specific matches) and cannot be deleted; custom routes can be modified or deleted. Multiple routes with different specificities are evaluated using longest-prefix matching, so a 10.0.0.0/16 route takes precedence over a 0.0.0.0/0 default route for destinations in that range.

11. Design a multi-tier VPC architecture for a production application with a web tier, application tier, and database tier. Each tier should have restricted communication between them. What GCP components would you use?

Create a single custom VPC with three subnets: web-subnet (10.0.1.0/24), app-subnet (10.0.2.0/24), and db-subnet (10.0.3.0/24). Use firewall rules with tags to enforce strict ingress/egress policies: allow web-tier VMs (tagged 'web') to receive traffic on port 80/443 from 0.0.0.0/0, allow app-tier VMs (tagged 'app') to receive traffic only from web-tier VMs on port 8080, and allow db-tier VMs (tagged 'db') to receive traffic only from app-tier VMs on port 3306. Use Cloud NAT on a custom route for each subnet to allow outbound internet access while maintaining internal isolation. Create a Cloud VPN or Interconnect for secure admin access to each tier, or use a bastion host in the web tier with strict SSH firewall rules (sourceRanges limited to admin IPs). This design minimizes blast radius: a compromised web VM cannot reach the database directly.

12. Your organization wants to migrate a legacy on-premises network to GCP with a hybrid setup using Cloud VPN. The on-premises network is 192.168.0.0/16 and your GCP VPC is 10.0.0.0/16. What are the key considerations and potential gotchas?

Ensure IP ranges do not overlap: 192.168.0.0/16 and 10.0.0.0/16 are separate, so this works. Create a Cloud VPN gateway in GCP and establish a site-to-site VPN tunnel to your on-premises VPN endpoint; configure BGP (Cloud Router) or static routes to advertise the GCP VPC CIDR and on-premises CIDR across the tunnel. Key gotchas: (1) the VPN bandwidth is limited by the tunnel capacity and internet uplink (use Cloud Interconnect for higher throughput); (2) DNS resolution may fail if on-premises DNS servers cannot reach GCP resources—configure Cloud DNS forwarding or dual DNS; (3) the VPN tunnel has higher latency than direct peering, affecting real-time systems. Test connectivity end-to-end before migrating production; use firewall rules on both sides to allow the VPN traffic. Plan for redundancy with dual VPN tunnels or a secondary Interconnect; consider a phased migration to avoid cutting off on-premises dependencies abruptly.

Practice these in a real mock interview
Get scored live and see ideal answers with an AI interviewer.
Start a Mock Interview →
← Previous
GCP VPC Interview Questions & Answers for Solutions Architect (Senior)
Next →
DataAnalyst SQL Joins Interview Questions & Answers for Data Analyst (Mid)

Related interview questions

GCP VPC Interview Questions & Answers for Solutions Architect (Senior)
GCP · 12 Qs
GCP VPC Interview Questions & Answers for Solutions Architect (Senior)
CICD Pipeline Design Interview Questions & Answers
CICD · 12 Qs
CICD Pipeline Design Interview Questions & Answers
CICD ArgoCD Interview Questions & Answers
CICD · 12 Qs
CICD ArgoCD Interview Questions & Answers
Data Analyst Interview Questions & Answers for Data Analyst (Mid-level)
Data Analyst · 12 Qs
Data Analyst Interview Questions & Answers for Data Analyst (Mid-level)