To control network traffic across your Google Cloud environment, manage global network firewall policies and their rules. This page describes how to list, describe, and update policies and their individual rules. You learn to clone rules between policies and manage policy associations with your Virtual Private Cloud (VPC) networks.
Before you read this page, ensure you are familiar with the concepts described in the Global network firewall policies overview .
Firewall policy tasks
This section describes how to manage global network firewall policies.
Describe a global network firewall policy
You can view details about a global network firewall policy, including the policy rules and the associated rule attributes. All these rule attributes are counted as part of the rule attribute quota. For more information, see "Rule attributes per global network firewall policy" in the Per firewall policy table.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project that contains the global network firewall policy.
-
Click your policy.
gcloud
gcloud compute network-firewall-policies describe POLICY_NAME \ --global
Update a global network firewall policy description
The only policy field that can be updated is the Descriptionfield.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project that contains the global network firewall policy.
-
Click your policy.
-
Click Edit.
-
In the Descriptionfield, change the text.
-
Click Save.
gcloud
gcloud compute network-firewall-policies update POLICY_NAME \ --description DESCRIPTION \ --global
List global network firewall policies
You can view a list of the policies available in your project.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project that contains the policy.
The Network firewall policiessection shows the policies available in your project.
gcloud
gcloud compute network-firewall-policies list --global
Remove the network association
If you need to change the global network firewall policy that's associated with a VPC network, we recommend that you first associate a new policy instead of deleting an existing associated policy. You can associate a new policy in one step, which helps to ensure that a global network firewall policy is always associated with the VPC network.
To delete an association between a global network firewall policy and a VPC network, follow the steps mentioned in this section. Rules in the global network firewall policy don't apply to new connections after its association is deleted.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project or the folder that contains the policy.
-
Click your policy.
-
Click the Associationstab.
-
Select the association that you want to delete.
-
Click Remove association.
gcloud
gcloud compute network-firewall-policies associations delete \ --firewall-policy FIREWALL_POLICY \ --name ASSOCIATION_NAME \ --firewall-policy-region FIREWALL_POLICY_REGION \ --global-firewall-policy
Delete a global network firewall policy
Before you can delete a global network firewall policy, you must delete all of its associations .
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project that contains the policy.
-
Click the policy that you want to delete.
-
Click the Associationstab.
-
Select all associations.
-
Click Remove association.
-
After all associations are removed, click Delete.
gcloud
Use the following command to delete the policy:
gcloud compute network-firewall-policies delete POLICY_NAME \ --global
Firewall policy rule tasks
This section describes how to manage global network firewall policy rules.
Clone rules from one policy to another
Cloning copies the rules from a source policy to a target policy, replacing all existing rules in the target policy.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project that contains the policy.
-
Click the policy from which you want to copy the rules.
-
Click Cloneat the top of the screen.
-
Provide the name of a target policy.
-
If you want to associate the new policy immediately, click Continue > Associate.
-
In the Associate policy with VPC networkspage, select the networks and click Associate.
-
Click Continue.
-
Click Clone.
gcloud
gcloud compute network-firewall-policies clone-rules TARGET_POLICY \ --global \ --source-firewall-policy SOURCE_POLICY
Replace the following:
-
TARGET_POLICY: the name of the target policy. -
SOURCE_POLICY: the URL of the source policy.
Describe a rule
You can view details about a specific rule in a global network firewall policy.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project that contains the policy.
-
Click your policy.
-
Click the priority of the rule.
gcloud
gcloud compute network-firewall-policies rules describe PRIORITY \ --firewall-policy= POLICY_NAME \ --global-firewall-policy
Replace the following:
-
PRIORITY: the priority number that uniquely identifies the rule. -
POLICY_NAME: the name of the policy that contains the rule.
Update a global network firewall policy rule
You can modify a global network firewall policy rule to change rule attributes, such as action on match, IP address ranges, or protocols and ports.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project that contains the global network firewall policy.
-
Click the name of the global network firewall policy that contains the rule to update.
-
Click the priority of the rule.
-
Click Edit.
-
Modify the firewall rule fields that you want to change. For descriptions about each field, see one of the following:
-
Click Save.
gcloud
gcloud compute network-firewall-policies rules update PRIORITY \ --firewall-policy= POLICY_NAME \ --global-firewall-policy \ [...other flags that you want to modify...]
Replace the following:
-
PRIORITY: the priority number that uniquely identifies the rule. -
POLICY_NAME: the name of the policy that contains the rule.
Supply the flags that you want to modify. For flag descriptions, see one of the following:
View effective firewall rules for a VM interface
You can view all firewall rules—from all applicable firewall policies and VPC firewall rules—that apply to a network interface of a Compute Engine VM.
Console
-
In the Google Cloud console, go to the VM instancespage.
-
In the project selector menu, select the project that contains the VM.
-
Click the VM.
-
For Network interfaces, click the name of the interface.
-
In Network configuration analysissection, click the Firewallstab.
-
To view the effective firewall rules, click Firewall rule viewtab.
gcloud
gcloud compute instances network-interfaces get-effective-firewalls INSTANCE_NAME \ [--network-interface INTERFACE ] \ [--zone ZONE ]
Replace the following:
-
INSTANCE_NAME: the VM for which you want to view the effective rules; if no interface is specified, the command returns rules for the primary interface (nic0). -
INTERFACE: the VM interface for which you want to view the effective rules; the default value isnic0. -
ZONE: the zone of the VM; this line is optional if the chosen zone is already set as the default.
View an effective firewall rules for a network
You can view all hierarchical firewall policy rules, VPC firewall rules, and global network firewall policy rules that apply to all regions of a VPC network.
Console
-
In the Google Cloud console, go to the VPC networkspage.
-
Click the network you want to view firewall policy rules for.
-
On the VPC network detailspage, click Firewallstab.
-
To view the rules that apply to this network, click Firewall rule viewtab.
gcloud
gcloud compute networks get-effective-firewalls NETWORK_NAME
Replace NETWORK_NAME
with the network for which you want
to view the effective rules.
You can also view effective firewall rules for a network from the Firewallpage.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
The firewall policies are listed in the Firewall policies inherited by this projectsection.
-
Click each firewall policy to view the rules that apply to this network.
Delete a rule from a policy
Deleting a rule from a policy causes the rule to no longer apply to new connections to or from the rule's target.
Console
-
In the Google Cloud console, go to the Firewall policiespage.
-
In the project selector menu, select your project that contains the policy.
-
Click your policy.
-
Select the rule that you want to delete.
-
Click Delete.
gcloud
gcloud compute network-firewall-policies rules delete PRIORITY \ --firewall-policy= POLICY_NAME \ --global-firewall-policy
Replace the following:
-
PRIORITY: the priority number that uniquely identifies the rule. -
POLICY_NAME: the name of the policy that contains the rule.

