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
- Click the Activate Cloud Shell icon at the top of the console page.
- Create the Custom Network and Subnets
- In the Cloud Shell, run the following command to create the network:
gcloud compute networks create la-network –subnet-mode custom - 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 - List the created network by running the following command:
gcloud compute networks subnets list –network la-network
- In the Cloud Shell, run the following command to create the network:
- Define the Firewall Rule
- 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
- Create the desired firewall rule by running the following command:
- Spin Up the VM Instances
- 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
- Create the Compute Engine instances by running the following commands:
- Test Via SSH
- From the Compute Engine VM console page, click the SSH button for the
la-vm-us
instance to open its SSH terminal. - In the SSH terminal, run the following commands to ping the VM instance in Europe:
ping -c 3 [EUROPE_VM_EXTERNAL_IP]
ping -c 3 [EUROPE_VM_INTERNAL_IP]
- From the Compute Engine VM console page, click the SSH button for the