Bitzu

Associate Cloud Engineer ยท Managing network resources

How do you grow a subnet and keep an IP address for yourself?

gcloud compute networks subnets expand-ip-range (expand only, never shrink), reserving static external and internal IPs, regional vs global addresses, in-use vs reserved cost.

Key points

  • gcloud compute networks subnets expand-ip-range NAME --prefix-length=N --region=R makes the primary range bigger; the new prefix must be smaller than the old one, and shrinking is impossible.
  • To keep an address, reserve it as a static address: regional for VMs, regional load balancers and NAT, global only for global load balancing.
  • Reserved addresses stay yours until released.

Source: https://docs.cloud.google.com/vpc/docs/subnets

Practice questions

Single choice

What happens to the primary IPv4 range of an existing subnet when you change its size?

  1. It can be expanded but never shrunk
  2. It can be shrunk but never expanded
  3. It can be freely expanded and shrunk
  4. It is fixed and can never be changed
Show answer

Answer: A. It can be expanded but never shrunk

A primary range can be expanded, but never shrunk or replaced. Deleting and recreating is the only way to get a smaller range.

Select all that apply

Which statements about static IP addresses in Google Cloud are true?

  1. A regional external address can be attached to a VM network interface
  2. A global external address is meant for global load balancing
  3. A reserved address remains in the project until you release it
  4. Ephemeral addresses survive deletion of the VM
  5. Static internal addresses are allocated from any region's pool
Show answer

Answer: A. A regional external address can be attached to a VM network interface, B. A global external address is meant for global load balancing, C. A reserved address remains in the project until you release it

Regional external addresses serve VMs and regional resources, while global external ones are for global load balancing. Static addresses stay in the project until released and can be moved between resources. Internal static addresses come from a subnet range, not from a global pool, and ephemeral addresses are generally released when the resource is deleted.

True or false

True or false: if a /20 subnet turns out to be too large, you can shrink it in place with expand-ip-range and a larger prefix length.

Show answer

Answer: False

False. The command only accepts a prefix that makes the range bigger. Shrinking requires recreating the subnet.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Associate Cloud Engineer topics in this module