Question

Difficulty: MediumDeploying Virtual Private Cloud (VPC) Networks, Subnets, and Firewall Rules

A Cloud Engineer is managing a custom-mode Virtual Private Cloud (VPC) network. A subnet named `app-subnet-us-east1` in region `us-east1` currently has a primary IP range of `10.1.0.0/24`. Due to rapid application growth, the subnet is running out of available IP addresses. The engineer needs to expand the primary subnet IP range to accommodate at least 500 private IP addresses without disrupting existing running Compute Engine instances or recreating the subnet. Which `gcloud` command should the engineer execute?

  1. Run `gcloud compute networks subnets expand-ip-range app-subnet-us-east1 --region=us-east1 --prefix-length=23`.Answer
  2. B
    Run `gcloud compute networks subnets expand-ip-range app-subnet-us-east1 --region=us-east1 --prefix-length=25`.
  3. C
    Delete `app-subnet-us-east1` using `gcloud compute networks subnets delete` and recreate it with CIDR `10.1.0.0/23`.
  4. D
    Run `gcloud compute instances update --zone=us-east1-a --subnet-prefix=23` for each instance connected to the subnet.

Answer

Run `gcloud compute networks subnets expand-ip-range app-subnet-us-east1 --region=us-east1 --prefix-length=23`.
In Google Cloud Virtual Private Cloud (VPC), primary subnet IP address ranges can be expanded in-place non-disruptively without recreating the subnet or taking VM instances offline. To expand a `/24` range (256 addresses) to fit at least 500 hosts, the prefix length must be reduced to `/23` (512 addresses). The correct command is `gcloud compute networks subnets expand-ip-range [SUBNET_NAME] --region=[REGION] --prefix-length=23`.

Step-by-Step Solution

1
Identify the required IP capacity for the subnet expansion
A /24 subnet provides 256 addresses (251 usable). Expanding to a /23 subnet provides 512 addresses (507 usable after reserved IPs), which satisfies the requirement of at least 500 host addresses.
Decreasing the CIDR prefix length integer (from 24 to 23) doubles the address space of the subnet.
2
Determine the correct gcloud CLI command for expanding subnet IP ranges non-disruptively
The command `gcloud compute networks subnets expand-ip-range` allows expanding the primary IP range of an existing subnet without stopping instances or recreating the network resource.
Google Cloud VPC subnets support in-place expansion of primary IP ranges provided the new netmask encompasses the current range and does not overlap with other subnets.
3
Select the correct flag parameters
The parameter `--prefix-length=23` correctly sets the new broader subnet mask length.
Subnet expansion requires specifying a smaller prefix length value than the current mask length.

Key Concept

Expanding VPC Subnet Primary IP Ranges in Google Cloud
Estimated Time:1m 30s
Rate this question