Build a Custom Network in Google Cloud Shell

45 minutes
  • 5 Learning Objectives

About this Hands-on Lab

Networks are the very backbone of cloud computing, and the ability to create a custom network is crucial. Custom networks allow custom subnets and firewall rules as well, so you can completely control access to your resources. In this hands-on lab, you’ll use the Google Cloud Shell to create a Cloud VPC network with two subnets, firewall rules that allow SSH ingress, and Compute Engine VM instances that connect to the subnets. Once the network and resources are established, you’ll test the connectivity of the networks via an SSH terminal.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Activate Cloud Shell
  1. Click the Activate Cloud Shell icon at the top of the console page.
Create the Custom Network and Subnets
  1. In the Cloud Shell, run the following command to create the network:
    gcloud compute networks create la-network –subnet-mode custom
  2. To create the subnets, run the following commands:
    gcloud compute networks subnets create la-subnet-us-central –network la-network –region us-central1 –range 10.0.1.0/24
    gcloud compute networks subnets create la-subnet-eu-west –network la-network –region europe-west1 –range 10.0.2.0/24
  3. List the created network by running the following command:
    gcloud compute networks subnets list –network la-network
Define the Firewall Rule
  1. Create the desired firewall rule by running the following command:
    gcloud compute firewall-rules create la-allow-ssh –allow tcp:22,icmp –network la-network
Spin Up the VM Instances
  1. Create the Compute Engine instances by running the following commands:
    gcloud compute instances create la-vm-us –subnet la-subnet-us-central –zone us-central1-a
    gcloud compute instances create la-vm-eu –subnet la-subnet-eu-west –zone europe-west1-b
Test Via SSH
  1. From the Compute Engine VM console page, click the SSH button for the la-vm-us instance to open its SSH terminal.
  2. In the SSH terminal, run the following command to ping the VM instance in Europe:
    ping -c 3 [EUROPE_VM_EXTERNAL_IP]

Additional Resources

Your team has a new internal app they want to start working on and you’ve been asked to create the initial custom network with two subnets—one in the US and another in Europe. You’ll also need to establish firewall rules that allow SSH access and two Compute Engine instances, one of each of the subnets. Finally, you’ll need to test the connectivity of the network from the US to the European instances.

You’ll need to complete the following steps to accomplish your task:

  1. Activate Cloud Shell.
  2. Create the custom network.
  3. Add custom subnets.
  4. Define firewall rules.
  5. Spin up VM instances.
  6. Test connectivity via SSH.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?