Skip to main content

Build a Custom Network in Google Cloud Shell

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:45:00

Difficulty

Beginner

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.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Build a Custom Network in Google Cloud Shell

Introduction

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.

Logging In to the Environment

  1. On the lab instructions page, right-click the Open GPC Console button.
  2. From the dropdown, select the option to open the link in a private browser window. (Note: Different browsers have different names for a private browser window. On Chrome, you'll choose Open Link in Incognito Window. If you're using Firefox, click Open Link in New Private Window. Etc.)
  3. On the Google sign-in page, enter the unique username you were provided on the lab instructions page. Click Next.
  4. Enter the unique password you were provided on the lab instructions page. Click Next.
  5. On the Welcome to your new account page, click Accept.
  6. In the Welcome L.A.! menu, check the box under Terms of service.
  7. Choose your country of residence, then click AGREE AND CONTINUE.

Activate Cloud Shell

  1. Click the Activate Cloud Shell icon at the top of the console page.
  2. Click START CLOUD SHELL.

Create the Custom Network and Subnets

  1. Create the network.
    gcloud compute networks create la-network --subnet-mode custom
  2. Create the subnets.
    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 network and subnets that we just created.
    gcloud compute networks subnets list --network la-network

Define the Firewall Rule

  1. Run the following command:
    gcloud compute firewall-rules create la-allow-ssh --allow tcp:22 --network la-network

Spin Up the VM Instances

  1. Run 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. Click the main navigation menu, and select Compute Engine > VM instances.
  2. Copy the external IP address for the la-vm-eu instance to your clipboard.
  3. Click the SSH button for the la-vm-us instance to open its SSH terminal.
  4. In the SSH terminal, run the following command to ping the VM instance in Europe:
    ping -c 3 [EUROPE_VM_EXTERNAL_IP] 

Conclusion

Congratulations, you've successfully completed this hands-on lab!