Virtual Private Cloud (VPC) in Google Cloud: Your Own Private Network Inside Google's Network
A beginner-friendly guide to how VPC networks, subnets, routes, firewall rules and connections work in Google Cloud, and how to design a network that is organized, secure and ready to grow.
Imagine a huge shopping mall shared by thousands of businesses. Every shop has its own locked doors, its own staff corridors, its own signs and its own rules about who may walk in. Customers from the outside can only enter through the doors a shop chooses to open, while the shop’s staff move freely through private back passages. A Virtual Private Cloud, or VPC, gives your cloud resources exactly this kind of private space inside Google’s enormous shared infrastructure: your own network, with your own address plan, your own rules and your own doors.
1First, How Do Computers Talk to Each Other?
A few simple networking ideas make everything else in this guide easy.
Addresses
Every computer on a network needs an address so that others can find it, just like every house needs a street address. On the internet this address is called an IP address. A familiar example looks like four numbers separated by dots. Computers use these addresses to send small chunks of data, called packets, to each other.
Public and private addresses
Some addresses are public, meaning anyone on the internet can try to reach them. Others are private, reserved for use inside an organization and not reachable directly from the outside world. Home Wi-Fi networks use private addresses: your phone and laptop can talk to each other, but a stranger on the internet cannot reach them directly.
Ranges and CIDR
Networks group addresses into ranges. A range is written in a compact style called CIDR notation, such as a base address followed by a slash and a number. The number after the slash says how big the range is: a smaller number means a bigger range. Planning ranges is one of the most important jobs in network design, because ranges that overlap cannot be connected to each other easily.
Routers and firewalls
A router decides which path a packet should take to reach its destination, like a traffic signpost at a junction. A firewall decides whether a packet is allowed to pass at all, like a security guard checking tickets at a gate.
A network is a city. IP addresses are house numbers, ranges are neighborhoods, routers are the road signs that tell traffic which way to go, and firewalls are the guards at the gates deciding who may enter each neighborhood.
2So, What Is a VPC?
A virtual, software-defined version of a private network, living inside Google Cloud.
A Virtual Private Cloud network is a logically isolated network that you define inside Google Cloud. It looks and behaves like a traditional data center network, with address ranges, routes and firewalls, except it is created with software instead of cables and switches. Your virtual machines, containers and many managed services attach to it and communicate through it.
Because it is software-defined, creating a network takes seconds, changing it is quick, and you do not manage any physical equipment. Google runs the underlying infrastructure, including its huge private fiber network, and presents it to you as a simple set of building blocks.
Renting a private floor in a giant office tower: the building’s elevators, wiring and security systems belong to the landlord, but you decide which rooms exist on your floor, who gets a key card, and which doors are locked.
A VPC is not a physical network and it is not a single virtual machine. It is a configuration object that spans Google’s infrastructure. Nothing is “inside” it until you attach resources, and the rules you set decide who can talk to whom.
3What Makes Google Cloud’s VPC Special: It Is Global
A single network that can span the whole world.
In many cloud platforms, a virtual network is tied to one region, and connecting regions requires extra work. In Google Cloud, a VPC network is a global resource. One network can include subnets in many regions, and resources in different regions can communicate with each other using private addresses over Google’s own backbone, without you building special links between them.
The subnets themselves, however, are regional. A subnet lives in one region and spans all the zones in that region. So the structure is: one global network, containing several regional subnets, each holding resources placed in zones within that region.
flowchart TD
VPC[One Global VPC Network]
VPC --> R1[Subnet in Mumbai region]
VPC --> R2[Subnet in Frankfurt region]
VPC --> R3[Subnet in Iowa region]
R1 --> V1[VM in zone a]
R1 --> V2[VM in zone b]
R2 --> V3[VM in zone a]
R3 --> V4[VM in zone c]
Think of a company with one phone system covering offices in many countries. Employees in any office can dial each other using short internal numbers, because the system was designed as one network from the start rather than many separate ones stitched together.
A global VPC makes multi-region designs much simpler. You can deploy an application in two regions for resilience and let the two halves talk privately, with no separate routers or gateways to configure between them.
4Core Building Blocks You Must Know
The words you will use every day when working with VPC.
VPC Network
The global private network that contains your subnets, routes and firewall rules.
Subnet
A regional slice of the network with its own range of IP addresses where resources are placed.
Route
A rule that tells traffic which next stop to use for a given destination range.
Firewall Rule
A rule that allows or denies traffic to or from resources, based on direction, protocol, port and source or destination.
Internal IP Address
A private address used for communication inside the network. Every resource attached to a subnet has one.
External IP Address
A public address that lets a resource be reached from, or reach, the internet. It is optional.
Cloud Router
A managed service that exchanges route information dynamically between your VPC and other networks.
Cloud NAT
A managed service that lets resources without public addresses reach the internet for updates and downloads.
5Subnets and IP Address Planning
Good address planning prevents painful problems years later.
Auto mode and custom mode
Google Cloud offers two modes for creating networks. An auto mode network automatically creates one subnet in every region, using predefined address ranges. It is convenient for quick experiments, and the default network in a new project works this way. A custom mode network starts empty, and you create exactly the subnets and ranges you want. Custom mode is the recommended choice for production, because it gives you control and avoids clashes with other networks.
| Feature | Auto Mode | Custom Mode |
|---|---|---|
| Subnets created | Automatically, one per region | Only the ones you create |
| Address ranges | Predefined by Google | Chosen by you |
| Control | Limited | Full |
| Overlap risk with other networks | Higher, ranges are well known | Low, if you plan carefully |
| Best for | Learning and quick tests | Production and connected environments |
Planning ranges
When you create a subnet you choose its primary range. You can later enlarge a subnet’s range, but you cannot shrink it, and ranges within connected networks must not overlap. So the safe habit is to plan a company-wide address scheme first: decide which blocks belong to which environment, region or team, leave generous room to grow, and write it down.
Secondary ranges
A subnet can also have secondary ranges, extra address blocks used for special purposes. A common example is container platforms, where pods and services receive addresses from secondary ranges so they are first-class members of the network.
Planning address ranges is like planning a new town. If you lay out only a few tiny streets and later need a hospital and a school, you will have nowhere to put them. Reserving space for future neighborhoods costs little today and saves enormous trouble later.
Using the same address range in two networks that must later be connected, for example your cloud network and your office network. Overlapping ranges cannot be routed cleanly. Always check ranges across everything you might connect.
6Routes: Deciding Where Traffic Goes
Every packet needs directions.
A route is a rule that says, “traffic heading to this destination range should go to that next hop.” Google Cloud creates some routes automatically. For each subnet, a route is created so that resources in the network can reach each other. A default route to the internet is also created for the network, which is why a resource with an external address can reach the internet unless you remove or override that route.
You can add your own custom routes. For example, you might send all internet-bound traffic through a security appliance first, or point traffic for your office network toward a VPN tunnel. When several routes could apply, the most specific one wins, and priority numbers break ties.
Cloud Router can learn routes dynamically from other networks, such as your office or another cloud, using a standard protocol, so you do not have to type every route by hand. When your office adds a new network, the route appears in your VPC automatically.
Routes are like the signs at a highway interchange. One sign says “city center, this way,” another says “airport, take the next exit.” A packet reads the signs, picks the most specific one that matches its destination, and goes on its way.
Subnet routes
Created automatically for every subnet, so resources inside the network can find each other.
Default internet route
Sends traffic for unknown destinations toward the internet gateway. It only helps resources that have an external address or use Cloud NAT.
Custom static routes
Routes you create manually for special paths, such as through an inspection appliance or a VPN tunnel.
Dynamic routes
Routes learned automatically from connected networks through Cloud Router, which keeps hybrid setups up to date.
7Firewall Rules: The Security Guards
By default, the network is closed to outsiders, and you open only what you need.
VPC firewall rules control which traffic may enter or leave your resources. They are enforced at the level of each virtual machine’s network interface, so they protect resources even when those resources are in the same subnet. They are also stateful: if you allow a connection to start in one direction, the replies are automatically allowed back, so you do not need a mirror-image rule.
Implied rules
Every network has two built-in rules you cannot delete. One denies all incoming traffic, and one allows all outgoing traffic. They have the lowest priority, so any rule you create overrides them. This is why a new network is safe by default but your resources can still reach out to the world.
Anatomy of a rule
A rule has a direction (ingress for incoming, egress for outgoing), an action (allow or deny), a priority number, a target that says which resources it applies to, a source or destination, and the protocols and ports it covers. A lower priority number means the rule is checked first, so a priority of 100 beats a priority of 1000.
Targeting resources
Rules can target all resources in the network, resources with a particular network tag, or resources running as a particular service account. Using service accounts is generally the stronger choice, because tags can be changed by anyone who can edit a machine, while service accounts are controlled by identity permissions.
| Part of a Rule | What It Decides |
|---|---|
| Direction | Whether it covers incoming or outgoing traffic |
| Action | Allow or deny |
| Priority | Which rule wins when several match; lower number wins |
| Target | Which resources the rule protects |
| Source or destination | Which addresses or identities the rule talks about |
| Protocols and ports | Which kinds of traffic are covered |
Firewall rules are a guest list at a party. Everyone outside is turned away by default. You add names to the list, such as “friends may enter through the front door,” and the guard checks each arrival against the list in order of importance.
Firewall policies can also be attached at the level of an organization or a folder, so central security teams can set rules that apply to every project beneath them, while individual teams manage their own network-level rules.
8Reaching the Internet Safely: External IPs, Cloud NAT and Private Google Access
Many resources need to reach out, but very few need to be reachable from outside.
External IP addresses
Giving a resource an external address makes it reachable from the internet, subject to firewall rules. That is necessary for some public-facing services, but it increases exposure. A strong security habit is to give external addresses only to the few resources that truly need them.
Cloud NAT
NAT stands for network address translation. Cloud NAT is a managed service that lets resources with only private addresses start connections to the internet, for example to download software updates, while still not being reachable from the internet. It is not a proxy sitting on one machine; it is built into Google’s networking, so it scales without a single point of failure.
Private Google Access
Many Google services, such as storage and data tools, are reached through Google’s public service addresses. Private Google Access lets resources without external addresses reach those Google services using Google’s internal paths. This means a locked-down virtual machine can still read from a storage bucket without ever touching the public internet.
flowchart LR
VM[VM with only a private address]
VM -->|Outbound web traffic| NAT[Cloud NAT]
NAT --> NET[Internet]
VM -->|Private Google Access| GS[Google APIs and services]
NET -.->|Unsolicited inbound traffic blocked| VM
Cloud NAT is like a company switchboard operator. Employees can call out, and the outside world sees only the company’s main number. People outside cannot phone an individual employee’s desk directly.
9Connecting Networks Together
Real organizations rarely have just one network. Here are the ways to join them.
VPC Network Peering
Connects two VPC networks so their resources can talk using private addresses. It is simple and fast, but it is not transitive: if network A peers with B and B peers with C, A cannot automatically reach C. Address ranges must not overlap.
Shared VPC
Lets one central “host” project own the network while many “service” projects place their resources into it. Central teams control networking and security, while application teams control their own workloads. A popular choice for larger organizations.
Cloud VPN
Creates an encrypted tunnel over the public internet between your VPC and another network, such as an office. Quick to set up and relatively inexpensive, but its speed and reliability depend on the internet path.
Cloud Interconnect
A dedicated or partner-provided private link between your facility and Google, offering higher bandwidth and more predictable performance than VPN. Suited for heavy or sensitive hybrid traffic.
Private Service Connect
Lets you reach a service in another network, or a Google or partner service, through a private address inside your own network, without peering whole networks together or exposing the service publicly.
Network Connectivity Center
A hub that helps manage connectivity among many networks and sites from a central place, useful for larger hybrid and multi-site designs.
| Option | Connects | Key Characteristic |
|---|---|---|
| VPC Peering | Two VPC networks | Simple, private, not transitive |
| Shared VPC | Many projects into one network | Central control with delegated use |
| Cloud VPN | VPC and an outside network | Encrypted over the internet |
| Cloud Interconnect | VPC and an outside network | Private, high bandwidth, predictable |
| Private Service Connect | Clients and specific services | Service-level, not network-level, access |
flowchart TD
OFFICE[Office or Data Center] -->|Cloud VPN or Interconnect| CR[Cloud Router]
CR --> HUB[Shared VPC in Host Project]
HUB --> P1[Service Project: Web]
HUB --> P2[Service Project: Data]
HUB -->|VPC Peering| PART[Partner or Other VPC]
HUB -->|Private Service Connect| SVC[Published Service]
10Shared VPC in More Detail
How large companies keep networking tidy.
Imagine a company with fifty teams, each with its own Google Cloud project. If every team created its own network, there would be fifty different address plans, fifty sets of firewall habits and fifty separate connections to the office. It would be chaos, and security reviews would be a nightmare.
Shared VPC solves this by splitting responsibilities. A host project owns the network, with its subnets, routes, firewall rules and hybrid connections. Service projects are attached to it, and their resources, such as virtual machines and containers, are placed into subnets of the host’s network. Network administrators manage the shared network centrally, while project teams are granted permission to use only the specific subnets they need.
Designate a host project
Choose a project that will own the network and make it the host.
Build the network centrally
Create subnets, routes, firewall rules and hybrid connections once, following the company’s address plan.
Attach service projects
Link each team’s project to the host so it can use the shared network.
Grant subnet-level access
Give each team permission to use only the subnets meant for them, following least privilege.
Operate and review
Monitor traffic, review rules regularly, and add subnets as teams grow.
A shopping mall owner builds the corridors, security and entrances once. Each shop rents a unit and decorates it however it likes, but nobody redraws the mall’s main corridors on their own.
11Names, Load Balancing and Services Around the VPC
Networks work with several companion services.
Cloud DNS
Turns friendly names into addresses. Private zones let resources inside your network find each other by name without exposing those names publicly.
Cloud Load Balancing
Spreads incoming traffic across healthy resources, both for internet-facing and internal-only applications.
Cloud Armor
Protection against web attacks and floods of traffic at the edge, working together with certain load balancers.
Cloud IDS and Firewall Insights
Tools that detect suspicious traffic and help you find unused or overly broad firewall rules.
VPC Service Controls
A separate layer that draws a security boundary around Google-managed services such as storage and databases to reduce the risk of data leaving.
Network Intelligence Tools
Tools for testing connectivity, visualizing topology and diagnosing why traffic is or is not flowing.
VPC firewall rules control traffic between network resources. VPC Service Controls control which identities and networks may reach Google-managed services and where data may flow. They protect different things, and serious environments often use both.
12Life of a Packet: What Really Happens
Follow one request from a virtual machine to a database in another region.
sequenceDiagram
participant A as VM in Mumbai subnet
participant FW as Firewall check
participant R as Route lookup
participant BB as Google backbone
participant B as Database VM in Frankfurt subnet
A->>FW: Send packet to private address of database
FW->>FW: Egress rules allow it
FW->>R: Find best route
R->>BB: Subnet route matches
BB->>B: Deliver over private backbone
B->>FW: Ingress rules checked
FW-->>B: Allowed, packet accepted
B-->>A: Reply returns automatically as the connection is stateful
The key lesson is that two decisions are made for each packet: first, is it allowed by firewall rules, and second, is there a route that leads to its destination. If either answer is no, the packet does not arrive. When connectivity problems occur, checking those two things, in both directions, solves most cases.
Ask four questions in order: Are the two resources on networks that can reach each other? Does a route exist? Does a firewall rule allow the traffic in both places? Is the application itself listening on the right port? Connectivity testing tools can answer the first three for you.
13Designing a Network Step by Step
A practical recipe for a clean, secure first design.
List your environments and regions
Decide what you need: development, testing and production, and which regions they must run in.
Make a company-wide address plan
Allocate non-overlapping blocks per environment and region, including your office networks and any partners, with room to grow.
Choose the network structure
Use custom mode networks. Decide between one shared network and several separated ones, such as production apart from non-production.
Create subnets by purpose
Separate tiers such as web, application and data into different subnets or at least different rule targets, so rules can be specific.
Write minimal firewall rules
Start from denying everything and allow only the traffic each tier truly needs, targeting by service account where possible.
Decide how things reach the internet
Use Cloud NAT for outbound needs, load balancers for inbound traffic, and external addresses only when unavoidable.
Connect to offices and other networks
Select VPN or Interconnect, plan redundancy, and set up Cloud Router for dynamic routes.
Turn on visibility
Enable flow logs and firewall logging where useful, and set up monitoring and alerts before go-live.
14Security Layers for Your Network
Defense works best in layers.
Layer 1: Reduce exposure
Resources with no external address cannot be contacted directly from the internet. Use private addresses wherever possible, and place public-facing entry points behind load balancers with protections such as Cloud Armor.
Layer 2: Control traffic precisely
Write firewall rules that allow only necessary ports from necessary sources. Avoid broad rules that open everything to everyone. Use hierarchical policies for company-wide must-haves, such as blocking dangerous ports everywhere.
Layer 3: Separate environments
Keep production apart from development and testing, using separate networks or at least separate subnets and strict rules. Mistakes made in a test environment should never be able to touch live data.
Layer 4: Protect access to managed services
Use Private Google Access and Private Service Connect so traffic to Google and partner services stays off the public internet, and consider VPC Service Controls around sensitive data services.
Layer 5: Watch everything
Flow logs record samples of the connections crossing your network, firewall logs record rule hits, and audit logs record changes. Together they help detect attacks, prove compliance and investigate incidents.
flowchart TD
A[Few or no external addresses] --> B[Load balancer and Cloud Armor at the edge]
B --> C[Precise firewall rules and policies]
C --> D[Separated environments and subnets]
D --> E[Private access to Google services]
E --> F[Flow logs, firewall logs and audit logs]
Protecting a house means more than one lock. You have a fence, a locked gate, a locked door, an alarm and a camera. Each layer slows an intruder, and together they make a break-in unlikely and quickly noticed.
15Monitoring, Logging and Troubleshooting
Networks are invisible until something breaks, so build visibility early.
VPC Flow Logs
Records sampled network connections for subnets you choose, showing who talked to whom, how much data moved and when.
Firewall Rules Logging
Records when specific firewall rules allow or deny traffic, helping verify that rules behave as intended.
Connectivity Tests
Analyzes configuration to tell you whether a path between two points should work, and where it is blocked if not.
Network Topology and Performance Views
Visual maps and measurements of traffic, latency and packet loss across your network.
Logging everything all the time can be costly, so tune sampling rates and choose where detailed logs are truly needed, such as sensitive subnets and boundaries between environments. Alerts on unusual traffic spikes, blocked connection surges and tunnel failures give early warnings before users notice problems.
Use firewall insights to find rules that have not matched any traffic for a long time. Removing unused, overly broad rules reduces risk and makes the whole rule set easier to understand.
16Understanding Costs
The network itself is mostly free, but the traffic and add-ons are not.
Creating a VPC network, subnets and basic firewall rules generally does not carry a charge by itself. Costs come from what flows through and what you attach. Data leaving Google Cloud to the internet is charged. Traffic between regions is charged, and traffic between zones can be charged in certain cases, while traffic within a single zone using internal addresses is usually free. Managed components such as Cloud NAT, Cloud VPN, Cloud Interconnect, load balancers and external IP addresses each have their own pricing, and logging adds storage costs. Because rates and rules change, always check Google Cloud’s current pricing pages.
Keep chatty services close together
Place components that exchange a lot of data in the same region, and where possible the same zone, to reduce cross-region and cross-zone charges.
Remove unused external addresses
Reserved but idle public addresses can incur charges. Clean them up regularly.
Choose the right hybrid link
VPN is cheaper for light traffic. For large, steady volumes, Interconnect can be more economical per unit and more reliable.
Tune logging
Lower sampling rates and filter logs so you pay for the visibility you actually use.
Use private paths for Google services
Private Google Access keeps traffic within Google’s network and avoids unnecessary internet-bound costs and exposure.
17Advantages and Trade-offs
A balanced look at Google Cloud’s approach.
Advantages
- Global VPC simplifies multi-region designs with private connectivity over Google’s backbone.
- Software-defined, so networks are created and changed in seconds.
- Secure by default: inbound traffic is denied until you allow it.
- Shared VPC supports central control with delegated team access.
- Rich options for hybrid connectivity, including VPN and Interconnect.
- Deep integration with load balancing, DNS, logging and monitoring.
Disadvantages / Trade-offs
- Address planning mistakes are hard to fix later, especially overlapping ranges.
- Peering is not transitive, which can complicate large designs.
- The number of connection options can confuse newcomers.
- Traffic charges can surprise teams that do not design with data flow in mind.
- Concepts and defaults differ from other clouds, so skills need adjusting when moving between providers.
18Best Practices and Anti-Patterns
Habits that keep networks healthy.
Best practices at a glance
Use custom mode networks
Create only the subnets and ranges you need, with a documented address plan.
Apply least privilege to traffic
Allow only specific ports and sources, and prefer service-account targeting over broad rules.
Avoid external addresses by default
Use Cloud NAT, load balancers and private access paths instead.
Separate environments
Keep production apart from development and testing with distinct networks or strict boundaries.
Build redundancy into hybrid links
Use more than one tunnel or connection so a single failure does not cut off your office.
Manage network configuration as reviewed, version-controlled definitions
Make changes traceable and repeatable, and avoid ad hoc edits in production.
Anti-patterns to avoid
Problem
Running production workloads in the default auto mode network.
Why It’s Harmful
Predefined ranges are likely to clash with other networks, and the default setup often includes permissive rules created for convenience.
Correct Approach
Create a custom mode network with a planned address scheme and tightly scoped rules.
Problem
Writing firewall rules that allow all traffic from anywhere to any port for convenience.
Why It’s Harmful
It exposes administration ports and services to the whole internet, a favorite target of automated attacks.
Correct Approach
Allow only required ports from known sources, and use secure access methods for administration rather than open remote-login ports.
Problem
Giving every virtual machine an external address.
Why It’s Harmful
Each public address is another door facing the internet, and many machines never needed to be reachable at all.
Correct Approach
Keep resources private, use Cloud NAT for outbound access and load balancers for inbound traffic.
Problem
Letting every team invent its own address ranges with no central plan.
Why It’s Harmful
Overlaps appear when networks are connected, forcing painful renumbering or complicated workarounds.
Correct Approach
Maintain a central address plan, and use Shared VPC or a clear allocation process.
19Frequently Asked Questions
The VPC network itself is global. Its subnets are regional, and each subnet spans all zones in its region.
Yes. Within one VPC network, resources in different regions communicate using internal addresses over Google’s backbone, as long as routes and firewall rules allow it.
Auto mode is fine for learning. For production, custom mode is recommended because you control ranges and avoid overlaps with other networks.
Incoming traffic is denied by default unless you add allow rules. Be careful with default networks, which may include convenient but permissive rules, and review them.
Peering connects two separate networks so they can exchange traffic. Shared VPC lets many projects use one centrally managed network. Peering links networks; Shared VPC shares a single network.
VPC peering is not transitive. Each connection works only between the two networks directly joined. To connect A and C you would peer them directly or use a hub-style design.
Use Cloud NAT for outbound internet access, or Private Google Access for reaching Google services, without making the machine reachable from the internet.
Yes. VPC firewall rules are enforced at each machine’s network interface, so they can control traffic even between machines in the same subnet.
VPN is quick and affordable for modest, less critical traffic. Interconnect suits large, steady or sensitive traffic and gives more predictable performance. Many organizations use both, one as a backup for the other.
You can expand a subnet’s primary range, but you cannot shrink it, and the new range must not overlap with others. This is why careful planning up front matters.
20Summary and Key Takeaways
A VPC is the foundation of almost everything you do in Google Cloud. It is a global, software-defined private network, made up of regional subnets, routes and firewall rules, which gives your resources private addresses, controlled paths and a secure-by-default posture. With Cloud NAT and Private Google Access, resources can stay private while still using the internet and Google services. With peering, Shared VPC, VPN, Interconnect and Private Service Connect, networks can be joined in the way your organization needs. Good results come from planning address ranges early, writing narrow firewall rules, keeping environments separate, adding visibility and watching traffic costs.
Key Takeaways
- Global network, regional subnets — one VPC can span the world, and resources in different regions can talk privately over Google’s backbone.
- Plan addresses first — use custom mode, avoid overlapping ranges, and leave room to grow, because ranges can be expanded but not shrunk.
- Secure by default, precise by design — incoming traffic is denied until allowed; write narrow, well-targeted rules, preferably using service accounts.
- Stay private — avoid external addresses, and use Cloud NAT, load balancers and Private Google Access instead.
- Pick the right connection — peering for network pairs, Shared VPC for central control, VPN or Interconnect for hybrid links, and Private Service Connect for service-level access.
- Layer your defenses — combine reduced exposure, firewall policies, environment separation, private service access and logging.
- Watch cost and visibility — keep chatty services close, tune logging, and use flow logs and connectivity tests to see and fix problems early.