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
What happens to the primary IPv4 range of an existing subnet when you change its size?
- It can be expanded but never shrunk
- It can be shrunk but never expanded
- It can be freely expanded and shrunk
- 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.
Which statements about static IP addresses in Google Cloud are true?
- A regional external address can be attached to a VM network interface
- A global external address is meant for global load balancing
- A reserved address remains in the project until you release it
- Ephemeral addresses survive deletion of the VM
- 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: 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.
