
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 instance
/ 5
Google Cloud Virtual Private Cloud (VPC) provides networking functionality to Compute Engine virtual machine (VM) instances, Kubernetes Engine containers, and 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 explore the connectivity for the VM instances.
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.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
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.
Notice the default network with its subnets. Each subnet is associated with a Google Cloud region and a private RFC 1918 CIDR block for its internal IP addresses range and a gateway.
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 Effective Routes tab, select the default
network and the
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.
Notice that there are 4 Ingress firewall rules for the default network: * default-allow-icmp * default-allow-rdp * default-allow-ssh * default-allow-internal
Verify that you cannot create a VM instance without a VPC network.
Create a VPC network so that you can create VM instances.
Replicate the default network by creating an auto mode network.
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 check or uncheck 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.
When the new network is ready, notice that a subnet was created for each region.
Create a VM instance in the
On 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 | mynet-us-vm |
Region | |
Zone | |
Series | E2 |
Machine type | e2-micro |
Click Create.
Verify that the Internal IP for the new instance was assigned from the IP address range for the subnet in
The Internal IP should be 10.128.0.2 because 10.128.0.1 is reserved for the gateway and you have not configured any other instances in that subnet.
Create a VM instance in the
Click Create Instance.
Specify the following, and leave the remaining settings as their defaults:
Property | Value (type value or select option as specified) |
---|---|
Name | mynet-eu-vm |
Region | |
Zone | |
Series | E2 |
Machine type | e2-micro |
Click Create.
Verify that the Internal IP for the new instance was assigned from the IP address range for the subnet in
The Internal IP should be
Click Check my progress to verify the objective.
Explore the connectivity for the VM instances. Specifically, try to SSH to your VM instances using tcp:22, and ping both the internal and external IP addresses of your VM instances using ICMP. Then explore the effects of the firewall rules on connectivity by removing the firewall rules individually.
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).
You can ping mynet-eu-vm's internal IP because of the allow-custom firewall rule.
Remove the allow-icmp firewall rule and try to ping the internal and external IP address of mynet-eu-vm.
On the Navigation menu (), click VPC network > Firewall.
Select the mynetwork-allow-icmp rule.
Click Delete.
Click Delete to confirm the deletion.
Wait for the firewall rule to be deleted.
Return to the mynet-us-vm SSH terminal.
To test connectivity to mynet-eu-vm's internal IP, run the following command, replacing mynet-eu-vm's internal IP:
You can ping mynet-eu-vm's internal IP because of the allow-custom firewall rule.
Remove the allow-custom firewall rule and try to ping the internal IP address of mynet-eu-vm.
Remove the allow-ssh firewall rule and try to SSH to mynet-us-vm.
In this lab, you explored the default network along with its subnets, routes, and firewall rules. You deleted the default network and determined that you cannot create any VM instances without a VPC network. Thus, you created a new auto mode VPC network with subnets, routes, firewall rules, and two VM instances. Then you tested the connectivity for the VM instances and explored the effects of the firewall rules on connectivity.
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