Skip to main content

Command Palette

Search for a command to run...

Configuring Networks via gcloud (GSP630) – Lab Notes 🧭 Overview

Updated
β€’3 min read

🌐 Configuring Networks via gcloud (GSP630) – Lab Notes

🧭 Overview

A Virtual Private Cloud (VPC) network in Google Cloud is a global resource that connects regional subnets through Google’s private WAN. It provides networking to:

  • Compute Engine VMs

  • Kubernetes Engine

  • App Engine Flex

In this lab, you:

  • Create two custom VPC networks

  • Add subnets

  • Configure firewall rules

  • Launch VM instances

  • Test public connectivity


πŸ—ΊοΈ VPC Network Architecture

https://docs.cloud.google.com/static/architecture/images/vpc-bps-native-firewall-rules.svg

https://miro.medium.com/1%2A6HWT7WGREFABwDf8poEqCQ.jpeg

https://miro.medium.com/v2/resize%3Afit%3A1400/1%2AT154Nb_X3YJYdzo9GDppJA.png


πŸ§ͺ Practical Lab Steps (GSP630)


βœ… Task 1: Create Custom VPC Network

gcloud compute networks create labnet --subnet-mode=custom

βœ” Creates custom mode VPC
βœ” No automatic subnets created


βœ… Task 2: Create Subnet

gcloud compute networks subnets create labnet-sub \
   --network labnet \
   --region us-central1 \
   --range 10.0.0.0/28

βœ” Region: us-central1
βœ” CIDR Range: 10.0.0.0/28


βœ… Task 3: View Networks

gcloud compute networks list

To describe a network:

gcloud compute networks describe labnet

βœ… Task 4: List Subnets

gcloud compute networks subnets list

πŸ”₯ Task 5: Create Firewall Rule (Allow Traffic)

gcloud compute firewall-rules create labnet-allow-internal \
    --network=labnet \
    --action=ALLOW \
    --rules=icmp,tcp:22 \
    --source-ranges=0.0.0.0/0

βœ” Allows:

  • ICMP (Ping)

  • TCP Port 22 (SSH)

βœ” Source: Public internet (0.0.0.0/0)


πŸ” Task 6: View Firewall Details

gcloud compute firewall-rules describe labnet-allow-internal

πŸ—οΈ Task 7: Create Second Network (Private Network)

Create Network

gcloud compute networks create privatenet --subnet-mode=custom

Create Subnet

gcloud compute networks subnets create private-sub \
    --network=privatenet \
    --region=us-central1 \
    --range=10.1.0.0/28

Create DENY Firewall Rule

gcloud compute firewall-rules create privatenet-deny \
    --network=privatenet \
    --action=DENY \
    --rules=icmp,tcp:22 \
    --source-ranges=0.0.0.0/0

βœ” Blocks Ping & SSH from public internet

List firewall rules:

gcloud compute firewall-rules list --sort-by=NETWORK

πŸ’» Task 8: Create VM Instances

Create VM in Private Network

gcloud compute instances create pnet-vm \
--zone=us-central1-a \
--machine-type=n1-standard-1 \
--subnet=private-sub

Create VM in labnet (Console Method)

  • Name: lnet-vm

  • Network: labnet

  • Subnet: labnet-sub

  • Machine Type: n1-standard-1


List VMs

gcloud compute instances list --sort-by=ZONE

Expected:

VM NameInternal IPExternal IPStatus
lnet-vm10.0.0.2Public IPRunning
pnet-vm10.1.0.2Public IPRunning

🌍 Task 9: Test Connectivity

Ping lnet-vm (Should Work)

ping -c 3 <lnet-vm-external-ip>

βœ” Works (Firewall allows traffic)


Ping pnet-vm (Should Fail)

ping -c 3 <pnet-vm-external-ip>

❌ Fails (Firewall denies traffic)


πŸ“Š Connectivity Flow Comparison

https://miro.medium.com/v2/resize%3Afit%3A1400/1%2AT154Nb_X3YJYdzo9GDppJA.png

https://docs.cloud.google.com/static/vpc/images/private-google-access.svg

https://storage.googleapis.com/gweb-cloudblog-publish/images/Network--Application-Security_v12-09-21_Px.max-2600x2600.jpg

4


🎯 Key Learning Points

βœ” Custom VPC does NOT create default firewall rules
βœ” Firewall rules are network-specific
βœ” Allow vs Deny rules control internet access
βœ” VM connectivity depends on firewall configuration


🏁 Result

Successfully:

  • Created 2 custom VPC networks

  • Created subnets

  • Applied firewall rules

  • Launched VM instances

  • Tested internet connectivity

More from this blog

googlecloudplatform

17 posts

Google Cloud Platform (GCP): Powering the Future of Cloud Computing Explore GCP β€” Scalable, Secure, and Intelligent Cloud by Google