0
0
GCPcloud~5 mins

Default VPC and subnets in GCP - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you create a Google Cloud project, it automatically creates a default network called the Default VPC. This network has subnets in each region, allowing your resources to communicate easily without extra setup.
When you want to quickly launch virtual machines without setting up a custom network.
When you need a simple network that connects resources across multiple regions automatically.
When you want to test or learn Google Cloud networking without configuring anything manually.
When you want to use Google Cloud services that require a network but don't need special network rules.
When you want to avoid the complexity of creating and managing custom subnets for small projects.
Commands
This command shows details about the Default VPC network in your Google Cloud project, including its subnets and settings.
Terminal
gcloud compute networks describe default
Expected OutputExpected
autoCreateSubnetworks: true creationTimestamp: '2023-01-01T12:00:00.000-07:00' description: Default network for project id: '1234567890123456789' kind: compute#network name: default selfLink: https://www.googleapis.com/compute/v1/projects/my-project/global/networks/default subnetworks: - https://www.googleapis.com/compute/v1/projects/my-project/regions/us-central1/subnetworks/default - https://www.googleapis.com/compute/v1/projects/my-project/regions/us-east1/subnetworks/default - https://www.googleapis.com/compute/v1/projects/my-project/regions/europe-west1/subnetworks/default autoCreateSubnetworks indicates this network has subnets in each region.
This command lists all the subnets created automatically in the Default VPC, showing their regions and IP ranges.
Terminal
gcloud compute networks subnets list --network=default
Expected OutputExpected
NAME REGION NETWORK RANGE default us-central1 default 10.128.0.0/20 default us-east1 default 10.132.0.0/20 default europe-west1 default 10.138.0.0/20
--network - Specifies the network to list subnets for
Key Concept

If you remember nothing else from this pattern, remember: the Default VPC automatically provides ready-to-use subnets in all regions so you can launch resources without manual network setup.

Common Mistakes
Trying to create a new subnet in the Default VPC manually.
The Default VPC uses automatic subnet creation, so manual subnet creation is not allowed and causes errors.
Use the Default VPC as is or create a custom VPC if you need manual subnet control.
Deleting the Default VPC without understanding its role.
Deleting the Default VPC can break existing resources that rely on it and cause network connectivity issues.
Only delete the Default VPC if you have a custom network ready and understand the impact.
Summary
The Default VPC is a ready-made network with automatic subnets in all regions.
Use 'gcloud compute networks describe default' to see Default VPC details.
Use 'gcloud compute networks subnets list --network=default' to list its subnets.