VPC Firewall Rules in Google Cloud: Priorities, Implied Rules, Tags and Service Accounts

GCP Study Hub
November 9, 2026

VPC firewall rules, part of Cloud NGFW, allow or deny traffic to and from VM network interfaces. Each rule has a direction, ingress for traffic arriving at the instances or egress for traffic leaving them, along with targets, sources or destinations, protocols and ports, an action and a priority. A handful of fixed behaviors decide how those rules interact: two implied rules at the bottom of every network, priority numbers where the smaller value wins, and stateful tracking of connections. The Professional Cloud Network Engineer exam also expects a clear sense of how rules select VMs, and why service accounts are preferred over network tags for workload identity.

The implied rules

Every VPC network has two implied rules at the lowest possible priority, 65535. One allows all egress traffic, and the other denies all ingress traffic. Because inbound traffic is already blocked by default, you usually only need to open what you want with ingress allow rules, and anything those rules do not match falls through to the implied deny.

How priority works

Priorities range from 0 to 65535, and the smaller number wins. That ordering matters whenever allow and deny rules overlap. An allow rule that carves an exception out of a broader deny rule needs a smaller priority number than the deny, or the deny matches first. In the same way, a broad deny placed at a very small number is evaluated ahead of the allow rules beneath it and blocks the traffic they were meant to permit.

Stateful behavior

VPC firewall rules are stateful. When a connection is allowed in one direction, the replies go back automatically. You never need an egress rule for replies to allowed inbound traffic, and egress rules do not control the reply packets of an inbound connection. Statefulness only covers replies, though. If the other side tries to start a new connection of its own, the implied ingress deny at the receiving end still blocks it unless a rule allows it. Allowing one workload to reach another therefore does not let the second workload open connections back to the first.

Protocols, ports and sources

Rules match on protocol and port, so the common mappings are worth knowing: HTTP uses TCP port 80, HTTPS uses TCP port 443, SSH uses TCP port 22 and RDP uses TCP port 3389. Opening the same port numbers for UDP is a separate permission that admits UDP traffic such as QUIC.

For instances with IPv4-only external addresses, a source range of 0.0.0.0/0 covers every client on the internet.

What firewall rules do not do

Firewall rules only allow or deny packets. They do not change which route a packet follows, and they cannot create a path that routing does not provide. They also have nothing to do with API calls that create resources. An egress allow rule does not give a VM without an external address a way to reach the internet, because the rule permits traffic but supplies no path for it.

Targets and sources: network tags and service accounts

A VPC firewall rule picks its targets by network tag or by service account. Resource labels are for organizing resources and tracking billing, and a firewall rule cannot be scoped to them.

Service accounts identify workloads more securely than network tags. Google recommends them for this kind of control because changing a VM's service account requires IAM permission on that account and requires stopping the VM. Network tags offer no such protection, since anyone who can edit instance tags could add a matching tag to another VM and gain the access the rule grants.

Matching on service accounts also identifies workloads by identity rather than by address. A rule can use one service account as the source and another as the target, so it matches particular workloads even when they draw their addresses from the same range.

Combining sources and targets

Two constraints govern how sources and targets combine:

  • A single rule cannot mix network tags and service accounts. A rule with a source tag and a target service account is rejected.
  • When a rule lists both source ranges and source identities (tags or service accounts), Google Cloud combines them with OR logic, so traffic that matches either one is admitted. A source range added to an identity-based rule widens the rule rather than narrowing it.

Since the implied rules leave egress open and ingress closed, we would usually approach a Professional Cloud Network Engineer connectivity scenario from the receiving workload and ask which ingress rule is missing.

Our Professional Cloud Network Engineer practice exams cover VPC firewall rules alongside hierarchical firewall policies and load balancer health checks, with detailed explanations that drill these distinctions.

Get tips and updates from GCP Study Hub

arrow