Prepare and test your skills

Prepare and test your skills

Adding a subnet to an existing VPC is the act of reserving a new regional address block inside that network for future resources. A Virtual Private Cloud (VPC) network is a global virtual network that holds routes and firewall rules, while each subnet is a regional resource that holds IP addresses for that region. The new subnet depends on its parent VPC network for routing, firewall policy, and global connectivity, while virtual machine (VM) instances in a zone depend on a subnet in the same region to obtain internal IP addresses.
Auto mode and custom mode VPC networks are the two modes that control how subnets are created and who controls address ranges. An auto mode network automatically creates one subnet in each region with a predefined IPv4 range, so it is simple to start but offers less control. A custom mode network creates no subnets automatically, so you define the name, region, and CIDR range for each subnet and must plan coverage region by region.
| Network mode | Subnet creation | Control and use |
|---|---|---|
| Auto mode | Google Cloud creates one subnet per region automatically | Simple to start with less control over ranges; can be converted to custom mode later |
| Custom mode | You create each subnet manually in chosen regions | Full control over region coverage and CIDR sizing; used for production planning |
An auto mode network can be converted to custom mode, and conversion preserves all existing subnets with their names and ranges unchanged. Conversion is one-way, and a converted network then operates exactly like a network created in custom mode. After conversion, tools must reference the subnet explicitly, including the --subnet flag in gcloud commands.
Planning valid CIDR ranges is the process of choosing a primary IPv4 block that fits inside the VPC network without overlapping another subnet. Every new IPv4-only subnet requires a unique name within the project, a region where its addresses will be reserved, and a primary IPv4 range in CIDR notation such as 10.0.1.0/24. A subnet belongs to one network in one region, so you cannot create VM instances in a region that has no subnet for that network.
The primary range and any secondary ranges must not overlap with existing primary or secondary ranges in the same network. Private RFC 1918 addresses are preferred for internal use, and any non-RFC 1918 range must be checked so it does not conflict with on-premises or cloud configurations. Secondary IPv4 ranges can be added at creation or later for uses such as container pods and services, but they follow the same non-overlapping rule.
Creating and validating a subnet is the workflow that attaches a new regional IP range to a selected VPC network and confirms it can host workloads. In the Google Cloud console, traffic flows from the VPC networks page to the new subnet definition, and the selected network becomes the parent of the subnet. The console requires the Compute Network Admin role to create the subnet.
--subnet=SUBNET_NAME to prove the link works.The gcloud path uses one command that links the subnet to its parent with the --network flag: gcloud compute networks subnets create SUBNET --network=NETWORK --range=PRIMARY_RANGE --region=REGION. After the instance starts, verification checks that DHCP configures the correct netmask and that ARP replies come from the expected ranges. Optional per-subnet settings such as Private Google Access and VPC Flow Logs can be enabled at creation or later by editing the subnet, and each subnet in the same VPC can have a different configuration.
Exam tip: Choose custom mode when you need to control regions and CIDR ranges, and remember that auto-to-custom conversion is one-way and keeps existing subnets unchanged.
Continue with this study guide: Adding a subnet to an existing VPC
Expanding a subnet to have more IP addresses is the process of increasing the usable addresses in an existing subnet while keeping it in the same region. A Virtual Private Cloud (VPC) (opens in a new tab) network is a global resource that holds regional subnets (opens in a new tab), and each subnet holds a primary IPv4 range for its region. Expansion grows that primary range so more VM instances, load balancers, and forwarding rules in the region can receive addresses from it.
Primary IPv4 expansion grows a subnet by changing its subnet mask to a smaller prefix length, which creates a larger address block. A smaller prefix number means a larger block, so moving from a longer prefix to a shorter prefix adds contiguous space around the original range. The subnet keeps its existing addresses, so current VMs keep their assigned IPs and do not need renumbering.
Expansion can take several minutes to complete, and traffic within the subnet is not interrupted during expansion. After expansion, other configurations that assumed the old range, such as firewall rules, routes, Cloud NAT, or address reservations, might need to be updated to recognize the larger range. Expanded addresses inherit the existing VPC routing behavior, where regional internal IPv4 addresses are advertised within the VPC network for VM-to-VM communication.
Limits and CIDR planning rules define when a larger primary IPv4 range is allowed and when it is blocked. The proposed new range must be a valid CIDR block that contains the original range and must not overlap any other primary or secondary range in the same VPC network. Expansion moves in one direction only, from a longer prefix to a shorter prefix, and does not support shrinking a subnet to a smaller range.
/16.The /16 limit exists because broader auto mode ranges would conflict with the other automatically created subnets that fit inside 10.128.0.0/9. Every primary IPv4 range also reserves four unusable IP addresses, so usable capacity is always four less than the total block size. Planning must therefore confirm that free address space exists next to the current range before requesting expansion.
Execution paths for subnet expansion are the console, gcloud command-line interface (CLI), and API methods that all act on the same regional subnet object. The console path uses the VPC networks page where subnets appear as entries within networks, while the gcloud path uses subnets update commands and the API path uses PATCH requests to the subnetworks.patch method with the current fingerprint. Permission to modify a subnet requires the Compute Network Admin role, and in a Shared VPC model expansion in the host project affects service projects on the other side of that project boundary.
| Expansion type | What changes on the subnet | Key constraint |
|---|---|---|
| Primary IPv4 range | Existing primary block becomes larger through a smaller prefix length | Must meet IPv4 range limits; auto-created subnets cannot go broader than /16; proxy-only subnets cannot be expanded |
| Secondary IPv4 range | New named secondary block is added alongside the primary block | Must use a valid range; an existing secondary range can be removed only when no resources use it |
To add a secondary range, traffic flows from the operator command to the subnet object, which then owns both ranges: gcloud compute networks subnets update SUBNET --region=REGION --add-secondary-ranges=SECONDARY_RANGE_NAME=SECONDARY_RANGE. To remove a secondary range, the command flows to the same subnet object only after all using resources have been removed. Operators should wait for primary expansion to reach its completed state before creating many new resources or changing dependent policies.
Exam tip: A smaller prefix number means a larger subnet — expansion makes the prefix smaller, auto-created subnets stop at /16, proxy-only subnets cannot be expanded, and in-subnet traffic is not interrupted.
Continue with this study guide: Expanding a subnet to have more IP addresses
Reserving static external or internal IP addresses is the process of holding a public or private address for a project so it persists until explicitly released. An ephemeral address is automatically assigned and is generally released when its resource is stopped or deleted, while a static address remains reserved for the project and can be moved between resources. Only one resource at a time can use a static address, and a Google-provided static external address is not announced to the internet until it is attached to a resource.
A static internal IP address is a named, regional address resource that holds a private address inside a VPC subnet. Each IPv4-only or dual-stack interface receives one primary internal IPv4 address from the subnet primary range, while each IPv6 interface connected to a subnet with an internal IPv6 range receives one /96 range from the subnet /64 range. Reserving the address prevents Google Cloud from giving that same address to another resource as an ephemeral address, which keeps private addressing stable for failover and service discovery.
| Address type | Lifetime | Use when |
|---|---|---|
| Ephemeral internal address | Released when the resource is generally stopped or deleted | The address does not need to survive replacement of the VM or forwarding rule |
| Static internal address (opens in a new tab) | Remains assigned to the project until explicitly released | The service depends on a stable private address that can move between resources |
The two workflows both depend on an existing VPC network with a subnet, and for IPv6 the subnet must have an internal IPv6 range. In the reserve-then-assign workflow, first choose a subnet, then reserve a named address from its range by letting Google Cloud choose the value or specifying a custom address, then assign it when creating the VM or internal load balancer. In the promote-in-use workflow, first create the instance with an ephemeral address, then promote the still-attached address to static by giving it a reservation name so the project keeps it after deletion.
Regional and global static external addresses differ in scope, tier, and which forwarding target they serve. A regional address is tied to one region and serves a zonal or regional resource in that region, while a global address is an anycast address that fronts a global load balancer across regions. Choose a regional address when the destination lives in one region, and choose a global address only when the destination is a global load balancer that needs one stable frontend.
| Address type | IP range size | Network tier | Reserved under |
|---|---|---|---|
| Regional external IPv4 (opens in a new tab) | /32 | Premium Tier or Standard Tier | Project |
| Regional external IPv6 | /96 | Premium Tier only | Subnet |
| Global external IPv4 | /32 | Premium Tier only | Project |
| Global external IPv6 | /64 | Premium Tier only | Project |
Regional external IPv4 addresses serve Compute Engine VM interfaces, external protocol forwarding, regional passthrough Network Load Balancers, and regional proxy and application load balancers, plus Cloud NAT and Cloud VPN gateways. Global addresses attach to a global forwarding rule that sends traffic to regional backends over the Premium Tier network. Regional external IPv6 addresses are reserved from a specific subnet external IPv6 range and stay associated with that subnet.
Promotion is the process that converts an ephemeral address already attached to a resource into a static reservation without changing its value. For external addresses, promoting does not cause Google Cloud to drop packets sent to the VM, including packets sent directly or through a load balancer. The promoted address stays attached to the same VM, so it must first be unassigned before it can be assigned to another resource.
networkIP, ipv6Address, or IPAddress value.The lifecycle moves from RESERVED to IN_USE and back to RESERVED until the reservation is deleted, and deleting a VM does not automatically release its static address. Existing reservations can be viewed in the console under External or Internal IP addresses, with gcloud compute addresses list, or with addresses.list and addresses.aggregatedList methods. If a static external address is reserved but not assigned, it is charged at a higher rate than an in-use address, so unused reservations should be reassigned or released promptly.
Exam tip: Deleting a VM does not release its static address, and an unassigned static external address costs more than an in-use address — release unused reservations to avoid extra charges.
Continue with this study guide: Reserving static external or internal IP addresses
Adding custom static routes in a VPC is the act of creating manual forwarding rules that direct packets leaving VMs toward a chosen next hop. A static route (opens in a new tab) belongs to exactly one VPC network and matches traffic by a single destination CIDR range. The route depends on a next-hop resource that must exist and be reachable from that network, and each VM controller stays informed of all applicable routes.
Route identity, destination, priority, and next hops are the fields that place a rule in one network and define which packets it matches and where it forwards them. The name must be unique within the project, the network setting means traffic flows from sources inside that one network to the configured next hop, and the destination is a single IPv4 or IPv6 CIDR such as 0.0.0.0/0 or ::/0. Priority uses numbers from 0 to 65,535, where a lower number means higher priority, so 0 wins before 1000 and 65,535 is lowest.
| Next-hop type | Sends packets to | Key requirement |
|---|---|---|
| Internet gateway | Internet and Google APIs and services | Use the default internet gateway for the project |
| VM instance | Network interface of a specific VM | Specify instance name and zone; for IPv6, instance must be dual-stack or IPv6-only |
| Instance IP address | IP address of an existing instance in the VPC | Address must belong to an existing instance in the same network |
| Classic VPN tunnel | Existing Classic VPN tunnel using static routing | Tunnel must already exist; route remains even if tunnel is not running |
| Internal passthrough Network Load Balancer | Forwarding rule of an internal passthrough Network Load Balancer | Specify forwarding rule name and region; IP versions must match |
In auto mode networks, do not create custom routes with destinations inside 10.128.0.0/9, because that range holds automatically created subnets and a new automatic subnet route can disable the custom route. A Classic VPN tunnel next hop in another region adds cost and latency because regional distance is not considered, so same-region placement is preferred.
How the VPC routing table selects a route is a two-level decision that compares destination specificity first and numerical priority second. Destination specificity means how closely a route destination matches the packet destination IP, with the longest and most exact match winning. Only when two or more applicable routes have the same destination does numerical priority decide, with the higher-priority route winning.
A decision tree that selects a VPC route by longest prefix match first, then lowest priority number, then ECMP split for ties.
Subnet routes always have the most specific destinations in the table because each subnet has at least one route whose destination matches its primary range. Subnet routes therefore protect paths to VMs and internal load balancers and cannot be overridden by another route even with higher priority. When custom static routes overlap with the same destination prefix, routes with the same priority distribute traffic across next hops using 5-tuple hash-based Equal-Cost Multi-Path (ECMP), while routes with different priorities create a preferred path and a redundant backup path.
Exam tip: Destination specificity beats priority — a more specific route always wins over a higher-priority but less-specific route, and lower priority numbers win ties.
Tagged routes are custom static routes that use network tags to limit which VMs use the route. A route without network tags applies broadly to all VMs in its network, while a route with network tags applies only to VMs that carry a matching tag. To limit a route, you add the tags field when you create the route, and traffic leaving a VM is checked against that tag list.
| Route type | Applies to | Resulting behavior |
|---|---|---|
| Route without network tags | All VMs in the VPC network | All VMs use the same destination and next hop for that destination |
| Route with network tags | Only VMs carrying a listed tag | Only tagged VMs use that destination and next hop; other VMs are unaffected |
Tagged routes create isolation because each group can have its own destination and next hop while sharing the same network. For example, VMs tagged egress-inet can receive default destination 0.0.0.0/0 to the internet while other VMs follow a different private path. Tagged traffic can also flow from tagged VMs through a specialized appliance, then onward to the destination, while untagged VMs bypass the appliance. Choose an instance or IP next hop when one appliance VM should receive the flow, and choose the load balancer next hop when several appliance VMs share load behind one forwarding rule.
Continue with this study guide: Adding custom static routes in a VPC
Working with Cloud DNS and Cloud NAT is the combined practice of controlling name resolution and controlled outbound connectivity for private workloads. Cloud NAT (opens in a new tab) is a distributed, software-defined translation service that provides outbound access without proxy VMs or a single gateway device, while Cloud DNS is a global authoritative DNS service that publishes names without requiring you to manage servers. Together they let private workloads resolve names in every environment but only initiate intended outbound connections.
How Cloud NAT enables outbound access is by sharing a set of external addresses and ports instead of giving each VM its own external IP. A Cloud NAT gateway is created in the same region as the subnets that need translation, and translation is then applied automatically to matching resources in those subnets. For example, VM-1 in subnet-1 has no external IP but needs to download updates, so outbound traffic flows from the VM internal address through the gateway to the internet destination.
The translation path depends on two planes with separate responsibilities. A Cloud Router provides the control plane that holds configuration parameters, while Andromeda software implements the data-plane translation on the physical machines that host the VMs. Cloud NAT performs source NAT on outbound packets and destination NAT only for established inbound response packets, so internet hosts cannot initiate new sessions into private VMs. Outbound access remains subject to egress firewall rules, and traffic to Google APIs uses Private Google Access even when the VM uses Public NAT.
Public NAT and Private NAT are the two translation types offered by Cloud NAT gateways. A single gateway provides either Public NAT or Private NAT, while two separate gateways can serve the same subnet when both types are needed. Both types can translate IPv4 to IPv4 and IPv6 to IPv4.
| NAT type | What it connects | How it translates |
|---|---|---|
| Public NAT | Resources without external IPv4 addresses to IPv4 destinations on the internet | Translates private internal addresses to shared external IP addresses and source ports |
| Private NAT | Private addresses to other VPC networks or on-premises and other-cloud networks | Translates overlapping private source addresses to unique addresses from the Private NAT subnet range |
Public NAT applies to Compute Engine VMs, Google Kubernetes Engine (GKE) clusters, Cloud Run and Cloud Run functions through Direct VPC egress or Serverless VPC Access, App Engine standard instances, and regional internet network endpoint groups (NEGs). Private NAT is used when IPv4 ranges overlap, because translation to unique addresses lets resources reach non-overlapping subnets on the other side, including VPCs attached to a Network Connectivity Center hub and on-premises networks connected through hybrid spokes, Cloud Interconnect, or Cloud VPN. With manual assignment, Public NAT uses a fixed set of external source addresses that can be shared for allowlisting, and with automatic allocation it can scale addresses for fleets including autoscaled managed instance groups.
Cloud DNS zones and records control which names resolve and who can resolve them. A managed zone is a container for records for a DNS namespace such as example.com, and you manage zones per project with Identity and Access Management (IAM) controls. A public zone is visible to the public internet for services such as www.example.com, while a private zone answers queries only from the VPC networks listed as its authorized networks.
| Zone type | Visible to | Use when |
|---|---|---|
| Public zone | The public internet | The service must be reachable by users outside Google Cloud |
| Private zone | Only authorized VPC networks | The service must stay internal, such as application servers or databases |
When a VM in an authorized network queries a private name, the query flows from the VM to Cloud DNS and Cloud DNS returns the private record answer. Records that share name, type, and TTL are managed together as a set, and TTL controls how long resolvers may cache answers. Common types are A for IPv4 addresses, AAAA for IPv6 addresses, CNAME for aliases to another name, MX for mail servers, TXT for verification text such as SPF, and PTR for reverse lookup from IP to name.
A hybrid hub-and-spoke design combines Cloud DNS forwarding with regional NAT gateways to connect a hub VPC, spoke VPCs, and on-premises. In this model, on-premises servers remain authoritative for corp.example.com, while Cloud DNS hosts a private zone such as projectX.gcp.example.com in each spoke. The hub provides inbound forwarding for on-premises queries and outbound forwarding to on-premises servers, with peering zones connecting hub to spokes, and firewalls on both sides must allow DNS traffic. The hub Cloud Router must advertise a custom route for 35.199.192.0/19 to on-premises so return traffic for the forwarding path can route correctly.
Availability comes from the distributed design, because translation does not depend on any customer VM or single gateway device and does not reduce per-VM bandwidth. Observability combines Cloud NAT logging for connections and bandwidth, gateway metrics sent automatically to Cloud Monitoring, and Network Analyzer insights from configuration monitoring. Because gateways are regional and serve only specified subnets, VPC design must place each gateway in the same region as the workloads that need translation.
Exam tip: Cloud NAT permits destination NAT only for established inbound responses to an outbound connection; it never creates a path for an unsolicited inbound connection.
Continue with this study guide: Working with Cloud DNS and Cloud NAT
/16, and cannot expand proxy-only subnets.An auto mode Virtual Private Cloud (VPC) network automatically creates one subnet in each region with a predefined IPv4 range, while a custom mode Virtual Private Cloud (VPC) network creates no subnets automatically so you define the name, region, and CIDR range for each subnet. Auto mode is simple to start but offers less control, and it can be converted to custom mode one-way with all existing subnets preserved with their names and ranges unchanged.
Expanding a Virtual Private Cloud (VPC) subnet grows its primary IPv4 range by moving to a smaller prefix length, which preserves existing addresses and does not interrupt traffic within the subnet. The proposed new range must contain the original range and must not overlap any other primary or secondary range in the same Virtual Private Cloud (VPC) network. Expansion cannot shrink a subnet, cannot expand an automatically created subnet broader than /16, and cannot expand a proxy-only subnet used exclusively for load balancer proxies.
Use a regional static external address when the destination lives in one region such as a Compute Engine virtual machine (VM) interface or regional load balancer, and use a global static external address only when the destination is a global load balancer frontend across regions. A regional address is tied to one region and serves a zonal or regional resource in that region, while a global address is an anycast address that fronts a global load balancer across regions.
The Virtual Private Cloud (VPC) routing table selects a route by destination specificity first and uses numerical priority only to break ties between routes with the same destination. The most specific longest prefix match always wins, and only then does the lower priority number win from 0 as highest to 65535 as lowest. Subnet routes always have the most specific destinations and cannot be overridden by another route even with higher priority.
Last updated