Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you restart it, you'll have to start from the beginning.
- On the top left of your screen, click Start lab to begin
Create a VPC with custom subnet mode.
/ 10
Create custom subnet within the labnet VPC
/ 10
Add firewall rules to allow tcp:22 and icmp
/ 10
Create another VPC, subnet and required deny firewall rules.
/ 30
Create VM instances
/ 40
A Virtual Private Cloud (VPC) network is a global resource which consists of a list of regional virtual subnetworks (subnets) in data centers, all connected by a global wide area network (WAN). VPC networks are logically isolated from each other in Google Cloud.
VPC provides networking functionality to Compute Engine virtual machine (VM) instances, Kubernetes Engine containers, and App Engine Flex. Each Google Cloud project by default has a default
network configuration which provides each region with an auto subnet network.
In this lab you use gcloud
to create two custom VPC networks with subnets, firewall rules, and VM instances, then test the networks' ability to allow traffic from the public internet.
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Install ping
to use later in this lab:
You can choose to create an auto mode
or custom mode
VPC network. Each new network that you create must have a unique name within the same project. You can create up to four additional networks in a project.
gcloud
command to create a custom mode network called labnet
:With this command you're doing the following:
gcloud
invokes the Cloud SDK gcloud
command line toolcompute
is a one of the groups available in gcloud
, part of a nested hierarchy of command groupsnetworks
is a subgroup of compute
with it's own specialized commandscreate
is the action to be executed on this grouplabnet
is the name of the network you're creating--subnet-mode=custom
you're passing the subnet mode flag and the type of subnet you're creating, "custom".Click Check my progress to verify the objective.
When you create a subnetwork, its name must be unique in that project for that region, even across networks. The same name can appear twice in a project as long as each one is in a different region.
Each subnet must have a primary range, which must be unique within the same region in a project.
labnet-sub
:Click Check my progress to verify the objective.
Your output should look like this:
describe
to view network details, such as its peering connections and subnets. Replace NETWORK_NAME
with the name of your network:You can list all subnets in all networks in your project, or you can show only the subnets for a particular network or region.
You'll see the subnet you created towards the bottom of the list. It's the only one in the labnet
network.
Auto networks include default rules, custom networks do not include any firewall rules. Firewall rules are defined at the network level, and only apply to the network where they are created.
The name you choose for each firewall rule must be unique to the project. To allow access to VM instances, you must apply firewall rules.
labnet-allow-internal
firewall rule:With this command you are doing the following:
firewall-rules
is a subcategory of compute
create
is the action you are takinglabnet-allow-internal
is the name of the firewall rule--network=labnet
puts the rule in the labnet
network--action=ALLOW
must be used with the --rules
flag, and is either "ALLOW" or "DENY"--rules=icmp,tcp:22
specifies the icmp and tcp protocols and the ports that the rule applies to--source-ranges=0.0.0.0/0
specifies the ranges of source IP addresses in CIDR format.Click Check my progress to verify the objective.
Now you'll create a another network, add firewall rules to it, then add VMs to both networks to test the ability to communicate with the networks.
This firewall rule denies all access from the internal protocol.
The output should look like this:
Click Check my progress to verify the objective.
Create two VM instances in the subnets:
private-sub
subnet:The output should look like this:
Property | Value |
---|---|
Name | lnet-vm |
Zone | |
Machine type | n1-standard-1 |
Subnet | labnet-sub |
You should see a similar output when your subnet is created.
For this command you're using the instance
subgroup, with it's specialized command list
.
You should see the 2 VMs you just created:
Click Check my progress to verify the objective.
When you created the networks, you applied firewall rules to each - so one network allows INGRESS traffic, and the other denies INGRESS traffic.
For this experiment, you should be able to communicate with the first network, but be unable to communicate with the second one.
This should work - lnet-vm
's network has a firewall rule that allows traffic.
pnet-vm
's external IP address.This should not work - nothing should be happening. pnet-vm
's network has a firewall rule that denies traffic. Use Ctrl+C to end the process.
In this lab you created two custom mode VPC networks, firewall rules, and VM instances using the Cloud Shell command line. Then you tested the ability of the VPC networks to receive traffic from the public internet.
Learn more about VPC networking:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated May 24, 2024
Lab Last Tested May 24, 2024
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
このコンテンツは現在ご利用いただけません
利用可能になりましたら、メールでお知らせいたします
ありがとうございます。
利用可能になりましたら、メールでご連絡いたします
One lab at a time
Confirm to end all existing labs and start this one