A firewall rule in Cloud Next Generation Firewall determines whether to allow or deny traffic
within a Virtual Private Cloud (VPC) network based on defined criteria. A
Cloud NGFW firewall policy lets you group several firewall rules so
that you can update them all at once, effectively controlled by
Identity and Access Management (IAM) roles.

This document provides an overview of the different types of firewall policies
and firewall policy rules.

## Firewall policies

Cloud NGFW supports the following types of firewall policies:

- [Hierarchical firewall policies](https://docs.cloud.google.com/firewall/docs/firewall-policies-overview.md.txt#hierarchical_firewall_policies)
- [Global network firewall policies](https://docs.cloud.google.com/firewall/docs/firewall-policies-overview.md.txt#global_network_firewall_policies)
- [Regional network firewall policies](https://docs.cloud.google.com/firewall/docs/firewall-policies-overview.md.txt#regional_network_firewall_policies)
- [Regional system firewall policies](https://docs.cloud.google.com/firewall/docs/firewall-policies-overview.md.txt#regional-system-firewall-policies)

### Hierarchical firewall policies

*Hierarchical firewall policies* let you group rules into a policy object that
can apply to many VPC networks in one or more projects. You can
associate hierarchical firewall policies with an entire
[organization](https://docs.cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy.md.txt#organizations)
or individual
[folders](https://docs.cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy.md.txt#folders).

For hierarchical firewall policy specifications and details, see
[Hierarchical firewall policies](https://docs.cloud.google.com/firewall/docs/firewall-policies.md.txt).

### Global network firewall policies

*Global network firewall policies* let you group rules into a policy object that
can apply to all regions of a VPC network.

For global network firewall policy specifications and details, see
[Global network firewall policies](https://docs.cloud.google.com/firewall/docs/network-firewall-policies.md.txt).

### Regional network firewall policies

*Regional network firewall policies* let you group rules into a policy object
that can apply to a specific region of a VPC network.

For regional firewall policy specifications and details, see
[Regional network firewall policies](https://docs.cloud.google.com/firewall/docs/regional-firewall-policies.md.txt).

### Regional system firewall policies

*Regional system firewall policies* are similar to regional network firewall
policies, but they are managed by Google. Regional system firewall policies
have the following characteristics:

- Google Cloud evaluates rules in regional system firewall policies
  immediately after evaluating rules in hierarchical firewall policies. For
  more information, see [Firewall rule evaluation process](https://docs.cloud.google.com/firewall/docs/firewall-policies-rule-eval-order.md.txt).

- You can't modify a rule in a regional system firewall policy, except to
  enable or disable firewall rule logging.

  <br />

- Google Cloud creates a regional system firewall policy in a region of
  a VPC network when a Google service requires rules in that
  region of the network. Google Cloud can associate more than one
  regional system firewall policy with a region of a VPC
  network based on the requirements of Google services.

- You aren't charged for the evaluation of rules in regional system firewall
  policies.

## Network profile interaction

Regular VPC networks support firewall rules in hierarchical
firewall policies, global network firewall policies, regional network firewall
policies, and VPC firewall rules. All firewall rules are
programmed as part of the [Andromeda network virtualization
stack](https://www.usenix.org/system/files/conference/nsdi18/nsdi18-dalton.pdf).

VPC networks that use certain [network
profiles](https://docs.cloud.google.com/vpc/docs/network-profiles) restrict the firewall policies and rule
attributes that you can use. For RoCE VPC
networks, see [Cloud NGFW for RoCE VPC
networks](https://docs.cloud.google.com/firewall/docs/firewall-for-roce) instead of this page.

## Firewall policy rules

In Google Cloud, a firewall policy rule has a direction that determines
whether it controls traffic coming into your network or traffic leaving it. Each
firewall policy rule applies to either incoming (ingress) or outgoing (egress)
connections.

### Ingress rules

Ingress direction refers to the incoming connections sent from specific sources
to Google Cloud targets. Ingress rules apply to inbound packets that
arrive on the following types of targets:

- Network interfaces of virtual machine (VM) instances.
- Managed Envoy proxies that power internal Application Load Balancers and internal proxy Network Load Balancers, including application layer inspection for cross-region internal Application Load Balancers.

An ingress rule with a `deny` action protects targets by blocking incoming
connections to them. If a rule with a higher priority allows traffic, the
firewall permits it and ignores any lower priority rules that might deny that
same traffic. Remember, higher priority rules always take precedence.

An automatically created default network includes some [pre-populated
VPC firewall
rules](https://docs.cloud.google.com/firewall/docs/firewalls#more_rules_default_vpc), which allow ingress for
certain types of traffic.

### Egress rules

Egress direction refers to the outbound traffic sent from a target
Google Cloud resource, such as a VM network interface, to a destination.

An egress rule with an `allow` action lets an instance send traffic to the
destinations specified in the rule. Egress traffic is blocked if it matches a
high priority `deny` rule. This action takes precedence over any lower priority
rules that might allow the traffic. Google Cloud also [blocks or
limits](https://docs.cloud.google.com/firewall/docs/firewalls#blockedtraffic) certain kinds of traffic.

## What's next

- To create and modify hierarchical firewall policies and rules, see [Create
  hierarchical firewall policies and
  rules](https://docs.cloud.google.com/firewall/docs/using-firewall-policies) and [Manage hierarchical
  firewall policies and rules](https://docs.cloud.google.com/firewall/docs/manage-hierarchical-firewall-policies).
- To create and modify global network firewall policies and rules, see [Create
  global network firewall policies and
  rules](https://docs.cloud.google.com/firewall/docs/use-network-firewall-policies) and [Manage global
  network firewall policies](https://docs.cloud.google.com/firewall/docs/manage-global-firewall-policies).
- To create and modify regional network firewall policies and rules, see [Create regional network firewall policies and
  rules](https://docs.cloud.google.com/firewall/docs/use-regional-firewall-policies) and [Manage regional
  network firewall policies](https://docs.cloud.google.com/firewall/docs/manage-regional-firewall-policies).