Let's create two subnets under the chap7 VPC (network) by following these steps:
- In order to create a subnet, you have to choose the region. By typing gcloud compute regions list you will know which regions are available to you:
Displaying a GCP region list
- Let's choose us-central1 and us-east1 to create two subnets under the chap7 VPC with the following configuration:
Subnet name | VPC | CIDR range | Region |
chap7-us-central1 | chap7 | 192.168.1.0/24 | us-central1 |
chap7-us-east1 | chap7 | 192.168.2.0/24 | us-east1 |
$ gcloud compute networks subnets create chap7-us-central1 --network=chap7 --range=192.168.1.0/24 --region us-central1
$ gcloud compute networks subnets create chap7-us-east1 --network=chap7 --range=192.168.2.0/24 --region us-east1
- Check the following command to see whether subnets are configured properly or not:
$ gcloud compute networks subnets list --network=chap7
NAME REGION NETWORK RANGE
chap7-us-east1 us-east1 chap7 192.168.2.0/24
chap7-us-central1 us-central1 chap7 192.168.1.0/24