Prepare and test your skills

Prepare and test your skills

A Virtual Private Cloud (VPC) network mode controls how subnetworks are created and who controls IP address ranges. Google Cloud offers two modes: auto mode, which creates subnetworks automatically, and custom mode, which requires manual creation. The choice affects control, planning effort, and the risk of address overlap.
An auto mode VPC network is a VPC network that automatically creates one subnetwork in every Google Cloud region. Google assigns a predefined IPv4 range to each subnetwork, so workloads can start in any region without manual setup. When Google opens a new region, the network automatically gains another subnetwork in that region. This design is simple for labs, tests, and small projects, but it gives little control over which ranges are used.
A custom mode VPC network is a VPC network that starts with no subnetworks and requires you to create each one manually. For each subnetwork (subnet), you choose the region and the IPv4 range, such as a block from private address space. All subnetworks in the same VPC can still reach each other because the VPC is one global network. Custom mode needs more planning, but it gives full control over where subnetworks live and how large they are.
Avoiding IP address overlaps means planning every range so it does not duplicate another network you must connect to. Overlaps cause failures when a VPC connects to an on-premises network, another VPC through peering or VPN, or services shared across projects. Custom mode helps because you define every range in advance, reserve space for future regions, and match the addressing plan used outside Google Cloud. Auto mode cannot give the same guarantee because its predefined ranges may already conflict with addresses you need.
The two modes differ in creation method and best use:
| Network Mode | How Subnetworks Are Created | When To Use It |
|---|---|---|
| Auto mode | Google creates one subnetwork per region automatically | Small projects, labs, and quick starts where ease matters more than control |
| Custom mode | You create each subnetwork and choose its region and IP range | Production and connected environments where ranges must be planned to avoid overlap |
Exam tip: An auto mode VPC network can be converted to custom mode, but a custom mode network cannot be converted back to auto mode.
Subnet configuration and IP address management is the practice of dividing a VPC into regional subnets with planned IP address ranges (opens in a new tab). Each subnet is tied to one region and holds a block of private addresses for resources in that region. Good planning prevents overlap, saves space for growth, and isolates workloads by location and environment.
Regional subnets are the building blocks that let one VPC serve resources in different geographic regions. A regional subnet is created by choosing a region and assigning a non-overlapping Classless Inter-Domain Routing (CIDR) range, such as 192.168.255.0/24. Resources deployed in that region receive IP addresses from that subnet, so traffic stays local and policies can isolate one region or environment from another. Choosing the region at creation supports localized deployment because compute, data, and application tiers can live in the subnet closest to their users and dependencies.
Non-overlapping CIDR ranges are private IP blocks that do not duplicate any other range in the VPC, its peered networks, or connected on-premises networks. Overlap causes routing conflicts, and for some services the range cannot be changed after it is set. Separate ranges for test and production also keep development work from affecting production workloads or security. Planning must include current use, future growth, and connections such as Virtual Private Network (VPN) or Interconnect to on-premises networks.
Three practical checks help avoid overlap before creating a subnet:
To view the ranges in use from the Google Cloud console, follow this ordered review:
The same inventory can be viewed with gcloud compute networks subnets list --sort-by=NETWORK, which lists all subnetworks grouped by network. Choose a range that does not appear in either view.
Subnet sizing determines how many usable IP addresses remain after Google Cloud reserves addresses for network functions. Every subnet reserves 4 addresses that cannot be assigned to nodes, so usable addresses equal total addresses minus 4. A /29 block has 8 total addresses and leaves 4 addresses for nodes, while larger blocks leave proportionally more room for growth. Small or full ranges cause failures when new resources try to start.
A Cloud Run service with direct VPC access cannot start new instances or job tasks when its subnet runs out of IPv4 addresses, and the exhaustion event is recorded by Cloud Logging. Allocated addresses can be inspected on the IP addresses page in the console or with gcloud compute addresses list. When a private service connection runs out of space, the fix is to expand the existing allocation or allocate an additional non-overlapping range and then update the VPC peering. Expansions must only increase the range, for example from 10.0.10.0/24 to at least 10.0.10.0/23, and a useful rule is to decrement the mask by 1 for each added condition such as an extra region.
Exam tip: Every subnet loses 4 reserved addresses, so a /29 leaves only 4 usable addresses, and overlapping or undersized ranges cannot be easily fixed after resources depend on them.
A Shared VPC (opens in a new tab) is a VPC network that lives in one central project but provides internal connectivity to virtual machine instances in other projects. The central project is called the host project, and the projects that use its network are called service projects. This design centralizes network administration while letting separate teams manage their own workloads.
A host project is the project that contains the Shared VPC network, its subnets, and centralized controls such as firewall rules and VPN connections. A service project is a project attached to a host project so its resources can use the host's subnets, even though the subnet and the instance are defined in different projects. A Shared VPC Admin enables the host project, attaches service projects, and grants network permissions, while a Service Project Admin manages instances inside one service project. A standalone project is neither a host nor a service project and does not use Shared VPC.
Shared VPC permissions control which subnets a Service Project Admin can use. Attaching a service project does not by itself grant access to any subnet. The Shared VPC Admin must still grant the Network User role (compute.networkUser) from the host project, either for the whole project or for selected subnets. A Service Project Admin needs at least subnet-level permission to create an instance that uses a shared subnet.
The two sharing scopes differ as follows:
| Sharing mode | Scope of access | Choose when |
|---|---|---|
| Project-level permissions | All current and future subnets in VPC networks of the host project | Every service project should be able to use any subnet |
| Subnet-level permissions | Only selected subnets in the host project | Different teams should be limited to specific subnets or regions |
Setting up a Shared VPC follows an ordered sequence:
compute.networkUser for the whole host project or for individual subnets, which defines who becomes a Service Project Admin for those subnets.Instance creation in a Shared VPC splits ownership between projects: the subnet and its IP range belong to the host project, while the instance belongs to the service project. The instance receives its internal IP address from the free addresses in the shared subnet, such as 10.0.1.3 from 10.0.1.0/24 in us-west1 or 10.15.2.4 from 10.15.2.0/24 in us-east1. The instance must be created in a zone in the same region as the subnet, so an instance using the 10.0.1.0/24 subnet in us-west1 must use a zone such as us-west1-a. By contrast, standalone instances are created by principals with at least the compute.InstanceAdmin role for that standalone project.
Exam tip: An instance must be in the same region as the shared subnet it uses, even though the subnet is in the host project and the instance is in the service project.
Multiple host projects create fully separate network environments for isolation. One pattern uses a Test environment host project with a Testing network and a Production environment host project with a Production network. In this pattern, Apps testing and Mobile testing attach only to the test host, while Apps production and Mobile production attach only to the production host. Both host networks can use the same CIDR ranges, such as 10.0.1.0/24 in us-west1 and 10.15.2.0/24 in us-east1, and an instance in testing and an instance in production can both use 10.0.1.3. This reuse is safe because each instance belongs to a different Shared VPC network, so test and production stay isolated while keeping identical addressing.
A hybrid Shared VPC uses a single host project whose Shared VPC network is connected by Cloud VPN to an on-premises network. Traffic flows from the on-premises network through the VPN connection into the host project's Shared VPC network, and then to instances in attached service projects such as Service project A, Service project B, and Service project C. Separate teams can manage each service project with no permissions in the other service projects, while all of them share the same central hybrid connection. The Shared VPC Admin controls the scope of sharing, so one team may receive only the 10.0.1.0/24 subnet, another may receive only the 10.15.2.0/24 subnet, and another may receive project-level access to any subnet in the host project.
An auto mode Virtual Private Cloud network automatically creates one subnetwork in every Google Cloud region with predefined IPv4 ranges, while a custom mode network starts with no subnetworks and requires you to create each subnetwork with its region and IPv4 range. All subnetworks in the same Virtual Private Cloud network can still reach each other because the network is global, and an auto mode network can be converted to custom mode but a custom mode network cannot be converted back to auto mode.
Use a custom mode network for production and connected environments where IP ranges must be planned to avoid overlap with on-premises networks, peering, or Virtual Private Network connections. Use an auto mode network for small projects, labs, and quick starts where ease of setup matters more than control over ranges.
A Shared VPC is a Virtual Private Cloud network that lives in one central host project but provides internal connectivity to virtual machine instances in other service projects. The host project contains the network, subnets, and centralized controls, while a service project is attached to the host so its instances can use the shared subnets after the Shared VPC Admin grants the Network User role for the whole project or for selected subnets.
Your company is configuring a custom mode VPC network named custom-vpc to host localized application workloads. The network already has an active subnet in the us-central1 region with a primary IP range of 10.0.1.0/24.
You need to add a new subnet for resources that will be deployed in the europe-west1 region while ensuring network isolation and preventing IP address conflicts.
Which gcloud command should you run to create the new subnet?
Run gcloud compute networks subnets create subnet-eu --network=custom-vpc --region=europe-west1 --range=10.0.2.0/24
Run gcloud compute networks subnets create subnet-eu --network=custom-vpc --global --range=10.0.2.0/24
Run gcloud compute networks subnets update custom-vpc --region=europe-west1 --add-subnets=10.0.2.0/24
Run gcloud compute networks subnets create subnet-eu --network=custom-vpc --region=europe-west1 --range=10.0.1.0/24
Last updated