
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 global firewall rules
/ 20
Migrate the VPC firewall rules
/ 10
Associate the global network firewall policy with your network
/ 10
Change the policy and rule evaluation order
/ 10
Enable logging of firewall rules
/ 10
Test the global network firewall policy
/ 20
Delete the VPC firewall rules from the network
/ 20
Cloud Next Generation Firewall (Cloud NGFW) is a cloud-first firewall service with advanced threat protection, micro-segmentation, and pervasive coverage to protect your Google Cloud workloads from internal and external attacks.
Global network firewall policies enable you to batch update all firewall rules by grouping them into a single policy object. You can assign network firewall policies to a Virtual Private Cloud (VPC) network. These policies contain rules that can explicitly deny or allow connections.
If you currently have VPC firewall rules, there is a migration tool to help you transition from legacy VPC rules to Cloud NGFW's firewall policies. The migration tool creates a global network firewall policy, converts the existing VPC firewall rules into firewall policy rules, and adds the new rules to the policy.
In this lab you will migrate a VPC firewall rule from an exiting network to a global network policy, then apply that policy to 2 VPC networks in your Google Cloud project.
For this lab it is presumed that you understand how to create a network and apply firewall rules. If you are unfamiliar, stop this lab and take the Create a Custom Network and Apply Firewall Rules lab first.
In this lab you will learn how to:
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 and zones. A region is a specific geographical location where you can run your resources. Each region has one or more zones.
gcloud
commands in Cloud Shell to set the default region and zone for your lab:For this lab, instead of controlling access through individual user accounts, network-level restrictions are being used. This means if you're on the "approved" external/partner networks, you're in. If not, you're blocked.
Identify the number of existing VPC firewall rules in your network
Global network firewall policy rules must be created in a global network firewall policy. The rules are not active until you associate the policy that contains those rules with a VPC network.
Each global network firewall policy rule can include either IPv4 or IPv6 ranges, but not both.
Click Check my progress to verify the objective.
After assessing your environment, migrate your VPC firewall rules to a global network firewall policy by using the compute firewall-rules migrate command. The migration tool creates the global network firewall policy based on the existing VPC firewall rules.
Replace the following:
NETWORK_NAME: the name of your VPC network containing the VPC firewall rules that you want to migrate. For this lab, use external-network
.
POLICY_NAME: give a name to the global network firewall policy that will be created during migration.
--replace-association-on-target
flag specifies that any existing association is deleted when you create the new association.
Watch the output for when the VPC firewalls are found, when the new network global firewall policy is created, and when the VPC firewall rules get migrated to it. After it's associated, the global firewall policy rules become active for VMs in the network.
Output:
Click Check my progress to verify the objective.
The migration tool creates the global network firewall policy based on the existing VPC firewall rules. You must manually associate the policy with the required VPC network to activate the policy rules for any VMs within that network. To associate the global network firewall policy, use the compute network-firewall-policies associations create
command.
Replace the following:
NETWORK_NAME: the name of your VPC network containing the firewall rules that you want to migrate. Replace this with external-network
.
POLICY_NAME: use the global network firewall policy that you just created.
The --replace-association-on-target
flag specifies that any existing association is deleted when you create the new association.
The output will confirm that you have only one global firewall policy.
Click Check my progress to verify the objective.
By default, Cloud Next Generation Firewall evaluates the VPC firewall rules before it evaluates a global network firewall policy. To make sure that global network firewall policies take precedence over VPC firewall rules, use the compute networks update
command to change the rule evaluation order.
Prioritize the Firewall Policy over legacy VPC Firewall rules.
external-network
:compute networks get-effective-firewalls
command.In the output of the preceding command, if TYPE: network-firewall-policy
is displayed before TYPE: network-firewall
, then the global network firewall policy is evaluated first.
Click Check my progress to verify the objective.
Firewall Rules Logging lets you audit, verify, and analyze the effects of your firewall rules. For example, you can determine if a firewall rule designed to deny traffic is functioning as intended. Firewall Rules Logging is also useful if you need to determine how many connections are affected by a given firewall rule.
Logging helps you to determine whether a firewall rule is functioning as intended. The migration tool retains the logging status of the existing VPC firewall rules when it creates the new global network firewall policy. To enable logging for firewall policy rules, use the compute network-firewall-policies rules update
command, and add in a priority order to ensure the globally policy takes precedence over legacy VPC firewall rules.
FIREWALL-POLICY: Replace with your global firewall policy name
To verify the firewall policy is attached to the network, return to VPC network in the Cloud console, and click on the external-network > Firewalls.
Click Check my progress to verify the objective.
Continued monitoring of hit counts reveals the gradual shift towards the new rules, with the legacy rules eventually receiving zero hits. At this point you should be able to disable the old rules, validate possible negative impacts, then delete the old legacy VPC firewall rules.
Now test your network-level access! if you're on the "approved" external networks, you're in. If not, you're blocked.
Send some traffic to the network that has the global firewall rule. You need to get the external IP address of VMs that are in your VPC Network.
external-server-1
Now move to Logs Explorer to see the results.
Check the logs
Check connectivity
For this test you'll use the Network Intelligence Center.
external-server-1
.internal-server-1
.You'll see that the test is unsuccessful - there is no firewall rule policy to allow tcp traffic to the internal-server-1
.
Now repeat the test, switching the direction. Add the internal-server-1
IP as the Source IP and the external-server-1
as the Destination.
Click Check my progress to verify the objective.
It is recommended that you disable the VPC firewall rules first before entirely deleting them. You can revert to those rules if the global network firewall policy created by the migration tool fails to provide the expected results. For this lab, move directly to removing the VPC firewall rules now that they are migrated to the global firewall policy.
Be sure to use the individual firewall rule names.
compute firewall-rules update
command.Replace RULE_NAME
with the name of the VPC firewall rule to be disabled.
compute firewall-rules delete
command.Optional: Delete firewall rules in the console
external-network
, then click on the Firewalls tab.Click Check my progress to verify the objective.
You have learned how to migrate a VPC firewall rule to a global firewall policy, applied it to 2 networks, verified that it is working, and disabled the legacy firewall rules in preparation of deleting them.
...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 April 4, 2025
Lab last tested April 4, 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