
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 custom network, subnetworks and firewall rules
/ 50
In this lab you will learn how to perform basic networking tasks on Google Cloud (including Compute Engine instances) and how Google Cloud might differ from an on-premises setup. You'll develop a network and 3 subnetworks, resulting in this end-state environment:
Finally, you'll learn how to create firewall rules and use instance tags to apply the firewall rules.
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.
Certain Compute Engine resources live in regions or zones. A region is a specific geographical location where you can run your resources. Each region has one or more zones. For example, the us-central1 region denotes a region in the Central United States that has zones us-central1-a
, us-central1-b
, us-central1-c
, and us-central1-f
.
Regions | Zones |
---|---|
Western US | us-west1-a, us-west1-b |
Central US | us-central1-a, us-central1-b, us-central1-d, us-central1-f |
Eastern US | us-east1-b, us-east1-c, us-east1-d |
Western Europe | europe-west1-b, europe-west1-c, europe-west1-d |
Eastern Asia | asia-east1-a, asia-east1-b, asia-east1-c |
Resources that live in a zone are referred to as zonal resources. Virtual machine Instances and persistent disks live in a zone. To attach a persistent disk to a virtual machine instance, both resources must be in the same zone. Similarly, if you want to assign a static IP address to an instance, the instance must be in the same region as the static IP.
Google Cloud supports projects, networks, and subnetworks to provide flexible, logical isolation of unrelated resources.
In Google Cloud, networks provide data connections into and out of your cloud resources (mostly Compute Engine instances). Securing your networks is critical to securing your data and controlling access to your resources.
Projects are the organizing entity for what you're building, for example the settings, permissions, and other metadata that describe your applications. Any Google Cloud resources you allocate and use must belong to a project.
Many developers map projects to teams since each project has its own access policy (IAM) and member list. Projects also collect billing and quota details reflecting resource consumption.
Resources within a single project work together, for example by communicating through an internal network, subject to the regions-and-zones rules. A project can't access another project's resources unless you configure a connection method such as Shared VPC or VPC Network Peering.
Networks directly connect your resources to each other and to the outside world. Networks, using firewalls, also house the access policies for incoming and outgoing connections. Networks can be global (offering horizontal scalability across multiple Regions) or regional (offering low-latency within a single region).
A VPC network is a virtual network inside of 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. VPC networks are logically isolated from each other in Google Cloud.
Subnetworks allow you to group related resources (Compute Engine instances) into RFC1918 private address spaces. Subnetworks can only be regional. A subnetwork can be in auto mode or custom mode.
Certain Compute Engine resources live in regions and zones. A region is a specific geographical location where you can run your resources. Each region has one or more zones.
Run the following gcloud
commands in Cloud Shell to set the default region and zone for your lab:
When a new project is created, a default network configuration provides each region with an auto subnet network. You can create up to four additional networks in a project. Additional networks can be auto subnet networks, custom subnet networks, or legacy networks.
Each instance created within a subnetwork is assigned an IPv4 address from that subnetwork range.
for more information on how you can use firewall rules to isolate subnetworks, refer to subnetworks and firewall rules.
Each network has a default firewall that blocks all inbound traffic to instances. To allow traffic to come into an instance, you must create "allow" rules for the firewall. Additionally, the default firewall allows traffic from instances unless you configure it to block outbound connections using an "egress" firewall configuration. Therefore, by default you can create "allow" rules for traffic you wish to pass ingress, and "deny" rules for traffic you wish to restrict egress. You may also create a default-deny policy for egress and prohibit external connections entirely.
In general, it is recommended to configure the least permissive firewall rule that will support the kind of traffic you are trying to pass. For example, if you need to allow traffic to reach some instances, but restrict traffic from reaching others, create rules that allow traffic to the intended instances only. This more restrictive configuration is more predictable than a large firewall rule that allows traffic to all of the instances. If you want to have "deny" rules to override certain "allow" rules, you can set priority levels on each rule and the rule with the lowest numbered priority will be evaluated first. Creating large and complex sets of override rules can lead to allowing or blocking traffic that is not intended.
The default network has automatically created firewall rules, which are shown below. No manually created network of any type has automatically created firewall rules. For all networks except the default network, you must create any firewall rules you need.
The ingress firewall rules automatically created for the default network are as follows:
|
Allows network connections of any protocol and port between instances on the network. |
|
Allows SSH connections from any source to any instance on the network over TCP port 22. |
|
Allows RDP connections from any source to any instance on the network over TCP port 3389. |
|
Allows ICMP traffic from any source to any instance on the network. |
All networks have routes created automatically to the Internet (default route) and to the IP ranges in the network. The route names are automatically generated and will look different for each project.
When manually assigning subnetwork ranges, you first create a custom network, then create the subnets you want within a region. You do not have to specify subnetworks for all regions right away, or even at all, but you cannot create instances in regions that have no subnetwork defined.
When you create a new 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. Because this is a subnetwork, there is no network-level IPv4 range or gateway IP, so none will be displayed.
You can either create your custom network with the console or with Cloud Shell. You'll be shown you both, but you have to decide which method to use while taking the lab. For example, you cannot go through a section using the instructions for the console, then go through the same section using gcloud
command line.
To create a custom network:
Click Navigation menu > VPC network.
Click Create VPC Network and name it taw-custom-network
.
On the Custom tab create:
10.0.0.0/16
Click Done.
Now click Add Subnet and add 2 more subnets in their respective regions:
Click Create to finish.
At this point, the network has routes to the Internet and to any instances that you might create. But it has no firewall rules allowing access to instances, even from other instances. To allow access, you must create firewall rules.
Continue to the Adding firewall rules section.
To allow access to VM instances, you must apply firewall rules. For this lab, you will use an instance tag to apply the firewall rule to your VM instances. The firewall rule will apply to any VM using the same instance tag.
Field |
Value |
Comments |
Name |
nw101-allow-http |
New rule name |
Targets |
Specified target tags |
Which instances to which the firewall rule applies. |
Target tags |
http |
The tag we created |
Source filter |
IPv4 ranges |
We will open the firewall for any IP address from the Internet. |
Source IPv4 ranges |
0.0.0.0/0 |
You will open the firewall for any IP address from the Internet. |
Protocols and ports |
Select Specified protocols and ports, then check the tcp box, and type 80 |
Only HTTP |
Your screen will look like this:
These additional firewall rules will allow ICMP, internal communication, SSH, and RDP. You can create them using the Console.
Field |
Value |
Comments |
Name |
nw101-allow-icmp |
New rule name |
Targets |
Specified target tags |
Select from the Targets dropdown |
Target tags |
rules |
tag |
Source filter |
IPv4 ranges |
We will open the firewall for any IP address on this list. |
Source IPv4 ranges |
0.0.0.0/0 |
We will open the firewall for any IP address from the Internet. |
Protocols and ports |
Select Specified protocols and ports, other protocols, then type icmp |
The protocols and ports the firewall applies to |
Field |
Value |
Comments |
Name |
nw101-allow-internal |
New rule name |
Targets |
All instances in the network |
Select from the Targets dropdown |
Source filter |
IPv4 ranges |
The filter used to apply the rule to specific traffic sources |
Source IPv4 ranges |
10.0.0.0/16, 10.1.0.0/16, 10.2.0.0/16 |
We will open the firewall for any IP address from the Internet. |
Protocols and ports |
Select Specified protocols and ports, then tcp and type 0-65535; check udp type 0-65535; check Other protocols and type icmp |
Allows Tcp:0-65535, udp:0-65535,icmp |
Field |
Value |
Comments |
Name |
nw101-allow-ssh |
New rule name |
Targets |
Specified target tags |
ssh |
Target tags |
ssh |
The instances to which you apply the firewall rule |
Source filter |
IPv4 ranges |
The filter used to apply the rule to specific traffic sources |
Source IPv4 ranges |
0.0.0.0/0 |
We will open the firewall for any IP address from the Internet. |
Protocols and ports |
Select Specified protocols and ports, check the tcp box, then type 22 |
Allows tcp:22 |
Field |
Value |
Comments |
Name |
nw101-allow-rdp |
New rule name |
Targets |
All instances in the network |
Select from the Targets dropdown |
Source filter |
IPv4 ranges |
Filter IP addresses |
Source IPv4 ranges |
0.0.0.0/0 |
We will open the firewall for any IP address from the Internet. |
Protocols and ports |
Select Specified protocols and ports, check the tcp, then type 3389 |
Allows tcp:3389 |
Click Check my progress to verify the objective.
When you have completed your lab, click End Lab. Your account and the resources you've used are removed from the lab platform.
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.
You have learned how default and user-created Networks are configured, how to add subnets, and apply firewall rules to control access.
...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 February 19, 2025
Lab last tested February 19, 2025
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.
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