
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 end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a VPC network and VM instances
/ 30
Create custom mode VPC networks with firewall rules
/ 40
Create VM instances
/ 30
Google Cloud Virtual Private Cloud (VPC) provides networking functionality to Compute Engine virtual machine (VM) instances, Kubernetes Engine containers, and the App Engine flexible environment. In other words, without a VPC network, you cannot create VM instances, containers, or App Engine applications. Therefore, each Google Cloud project has a default network to get you started.
You can think of a VPC network as similar to a physical network, except that it is virtualized within Google Cloud. A VPC network is a global resource that 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.
In this lab, you create an auto mode VPC network with firewall rules and two VM instances. Then, you convert the auto mode network to a custom mode network and create other custom mode networks as shown in the example network diagram below. You also test connectivity across networks.
In this lab, you learn how to perform the following tasks:
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel 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 panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Each Google Cloud project has a default network with subnets, routes, and firewall rules.
The default network has a subnet in each Google Cloud region.
Routes tell VM instances and the VPC network how to send traffic from an instance to a destination, either inside the network or outside Google Cloud. Each VPC network comes with some default routes to route traffic among its subnets and send traffic from eligible instances to the internet.
In the left pane, click Routes.
In the Network dropdown list, click default.
In the Region dropdown list, click
Click View.
Notice that there is a route for each subnet and one for the Default internet gateway (0.0.0.0/0).
These routes are managed for you, but you can create custom static routes to direct some packets to specific destinations. For example, you can create a route that sends all outbound traffic to an instance configured as a NAT gateway.
Each VPC network implements a distributed virtual firewall that you can configure. Firewall rules allow you to control which packets are allowed to travel to which destinations. Every VPC network has two implied firewall rules that block all incoming connections and allow all outgoing connections.
In the left pane, click Firewall.
Notice that there are 4 Ingress firewall rules for the default network:
These firewall rules allow ICMP, RDP, and SSH ingress traffic from anywhere (0.0.0.0/0) and all TCP, UDP, and ICMP traffic within the network (10.128.0.0/9). The Targets, Filters, Protocols/ports, and Action columns explain these rules.
Wait for the network to be deleted before continuing.
Notice that there are no routes.
Notice that there are no firewall rules.
Verify that you cannot create a VM instance without a VPC network.
An error is shown on the Networking tab.
Click Go to Issues.
In Network Interfaces, notice the No more networks available error under Network interfaces.
Click Cancel.
You have been tasked to create an auto mode network with two VM instances. Auto mode networks are easy to set up and use because they automatically create subnets in each region. However, you don't have complete control over the subnets created in your VPC network, including regions and IP address ranges used.
Feel free to explore in the Google VPC documentation for more considerations for choosing an auto mode network, but for now, assume that you are using the auto mode network for prototyping purposes.
Auto mode networks create subnets in each region automatically.
These are the same standard firewall rules that the default network had. The deny-all-ingress and allow-all-egress rules are also displayed, but you cannot select or disable them because they are implied. These two rules have a lower Priority (higher integers indicate lower priorities) so that the allow ICMP, custom, RDP, and SSH rules are considered first.
Click Create.
When the new network is ready, click mynetwork > Subnets. Note the IP address range for the subnets in
Create a VM instance in the
In the Navigation menu (), click Compute Engine > VM instances.
Click Create Instance.
Specify the following:
Property | Value (type value or select option as specified) |
---|---|
Name | mynet-us-vm |
Region | |
Zone |
For Series, select E2.
For Machine type, select e2-micro (2 vCPU, 1 GB memory).
Click OS and storage.
If the Image shown is not Debian GNU/Linux 12 (bookworm), click Change and select Debian GNU/Linux 12 (bookworm), and then click Select.
Click Create.
Create a VM instance in the
Click Create instance.
Specify the following:
Property | Value (type value or select option as specified) |
---|---|
Name | mynet-notus-vm |
Region | |
Zone |
For Series, select E2.
For Machine type, select e2-micro (2 vCPU, 1 GB memory).
Click OS and storage.
If the Image shown is not Debian GNU/Linux 12 (bookworm), click Change and select Debian GNU/Linux 12 (bookworm), and then click Select.
Click Create.
Note: The External IP addresses for both VM instances are ephemeral. If an instance is stopped, any ephemeral external IP addresses assigned to the instance are released back into the general Compute Engine pool and become available for use by other projects.
When a stopped instance is started again, a new ephemeral external IP address is assigned to the instance. Alternatively, you can reserve a static external IP address, which assigns the address to your project indefinitely until you explicitly release it.The firewall rules that you created with mynetwork allow ingress SSH and ICMP traffic from within mynetwork (internal IP) and outside that network (external IP).
Note the external and internal IP addresses for mynet-notus-vm.
You can ping mynet-notus-vm's internal IP because of the allow-custom firewall rule.
The auto mode network worked great so far, but you have been asked to convert it to a custom mode network so that new subnets aren't automatically created as new regions become available. This could result in overlap with IP addresses used by manually created subnets or static routes, or could interfere with your overall network planning.
Wait for the Mode of mynetwork to change to Custom.
You can click Refresh while you wait.
Click Check my progress to verify the objective.
You have been tasked to create two additional custom networks, managementnet and privatenet, along with firewall rules to allow SSH, ICMP, and RDP ingress traffic and VM instances as shown in this example diagram (with the exception of vm-appliance):
Note that the IP CIDR ranges of these networks do not overlap. This allows you to set up mechanisms such as VPC peering between the networks. If you specify IP CIDR ranges that are different from your on-premises network, you could even configure hybrid connectivity using VPN or Cloud Interconnect.
Create the managementnet network using the Cloud console.
In the Google Cloud console, on the Navigation menu (), click VPC network > VPC networks.
Click Create VPC Network.
For Name, type managementnet
For Subnet creation mode, click Custom.
Specify the following, and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Name | managementsubnet-us |
Region | |
IPv4 range | 10.240.0.0/20 |
Click Done.
Click Equivalent Command line.
These commands illustrate that networks and subnets can be created using the gcloud
command line. You will create the privatenet network using these commands with similar parameters.
Click Close.
Click Create.
Create the privatenet network using the gcloud
command line.
The output should look like this:
Create firewall rules to allow SSH, ICMP, and RDP ingress traffic to VM instances on the managementnet network.
In the Google Cloud console, in the Navigation menu (), click VPC network > Firewall.
Click Create firewall rule.
Specify the following, and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Name | managementnet-allow-icmp-ssh-rdp |
Network | managementnet |
Targets | All instances in the network |
Source filter | IPv4 Ranges |
Source IPv4 ranges | 0.0.0.0/0 |
Protocols and ports | Specified protocols and ports |
Select tcp and specify ports 22 and 3389.
Select Other protocols and specify icmp protocol.
Click Equivalent Command line.
These commands illustrate that firewall rules can also be created using the gcloud
command line. You will create the privatenet's firewall rules using these commands with similar parameters.
Click Close.
Click Create.
Create the firewall rules for privatenet network using the gcloud
command line.
The output should look like this:
The output should look like this:
The firewall rules for mynetwork network have been created for you. You can define multiple protocols and ports in one firewall rule (privatenet and managementnet) or spread them across multiple rules (default and mynetwork).
Click Check my progress to verify the objective.
Next, create two VM instances:
Create the managementnet-us-vm instance using the Cloud console.
In the Google Cloud console, in the Navigation menu (), click Compute Engine > VM instances.
Click Create instance.
Specify the following, and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Name | managementnet-us-vm |
Region | |
Zone | |
Series | E2 |
Machine type | e2-micro (2 vCPU, 1 core, 1 GB memory) |
Boot disk | Debian GNU/Linux 12 (bookworm) |
Click Networking.
For Network interfaces, click the dropdown arrow to edit.
Specify the following, and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Network | managementnet |
Subnetwork | managementsubnet-us |
Click Done.
Click Equivalent Code.
This illustrates that VM instances can also be created using the gcloud
command line. You will create the privatenet-us-vm instance using these commands with similar parameters.
Click Create.
Create the privatenet-us-vm instance using the gcloud
command line.
Verify that the VM instances are listed in the Cloud console.
For Columns, select Zone.
There are three instances in
Click Check my progress to verify the objective.
Explore the connectivity between the VM instances. Specifically, determine the effect of having VM instances in the same zone versus having instances in the same VPC network.
Ping the external IP addresses of the VM instances to determine whether you can reach the instances from the public internet.
In the Google Cloud console, in the Navigation menu, click Compute Engine > VM instances.
Note the external IP addresses for mynet-notus-vm, managementnet-us-vm, and privatenet-us-vm.
For mynet-us-vm, click SSH to launch a terminal and connect. Click Authorize if prompted.
To test connectivity to mynet-notus-vm's external IP, run the following command, replacing mynet-notus-vm's external IP:
This should work!
This should work!
This should work!
Ping the internal IP addresses of the VM instances to determine whether you can reach the instances from within a VPC network.
In this lab, you explored the default network and determined that you cannot create VM instances without a VPC network. Thus, you created a new auto mode VPC network with subnets, routes, firewall rules, and two VM instances and tested the connectivity for the VM instances. Because auto mode networks aren't recommended for production, you converted the auto mode network to a custom mode network.
Next, you created two more custom mode VPC networks with firewall rules and VM instances using the Cloud console and the gcloud command line. Then you tested the connectivity across VPC networks, which worked when pinging external IP addresses but not when pinging internal IP addresses.
VPC networks are by default isolated private networking domains. Therefore, no internal IP address communication is allowed between networks, unless you set up mechanisms such as VPC peering or VPN.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 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.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one