Security control at the VPC level
Firewall rules are attached to the VPC network model rather than to a single subnet object. That makes them powerful, but it also means teams need to be deliberate about targets and scope.
Firewall rules are one of the most important security controls in Google Cloud networking. They decide whether traffic is allowed or denied as it enters or leaves VM instances, and they work together with VPC design, subnets, routes, load balancers, Cloud NAT, and hybrid connectivity.
Understanding firewall rules is critical because many network problems that look like routing or subnet issues are actually firewall problems. Once you understand direction, action, priority, targets, sources, destinations, protocols, and logging, Google Cloud traffic behavior becomes much easier to reason about. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Google Cloud firewall rules are VPC-level controls that specify whether traffic is allowed or denied based on attributes such as direction, action, priority, source or destination, target, protocol, and port. These rules apply to traffic for VM instances, including workloads behind services that ultimately depend on VM networking behavior. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Firewall rules are attached to the VPC network model rather than to a single subnet object. That makes them powerful, but it also means teams need to be deliberate about targets and scope.
A rule can explicitly allow or deny traffic. When multiple rules could apply, Google Cloud evaluates them according to documented priority behavior. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Firewall issues are among the most common reasons workloads cannot reach each other, the internet, or hybrid destinations.
Google Cloud evaluates firewall rules by direction and then applies the highest-priority matching rule. Lower numeric priority values have higher precedence. Rules are stateful, which means that allowed connections are tracked so return traffic for those connections is automatically permitted. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Firewall rules are either ingress or egress. Ingress controls incoming traffic to targeted instances, while egress controls outgoing traffic from them.
When more than one rule could match, Google Cloud uses priority to determine which rule is evaluated as the effective decision. Lower number means higher priority. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Rules can target all instances in a network or more specific groups by service account or network tag, depending on your design. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Ingress rules match source ranges or source tags and service accounts, while egress rules use destinations and outbound criteria.
Rules can allow or deny traffic for protocols such as TCP, UDP, ICMP, and specific ports or port ranges.
Because the firewall is stateful, teams do not have to create separate return-path rules for every allowed connection pattern. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Understanding direction is one of the fastest ways to avoid firewall confusion. Many troubleshooting delays happen because teams think a traffic problem is inbound when it is actually outbound, or vice versa.
Ingress rules control traffic entering targeted VM instances. Typical examples include allowing HTTPS from the internet, SSH from admin networks, or app-to-database communication from a trusted subnet range.
Egress rules control outbound traffic from targeted VM instances. Typical examples include permitting updates to external package repositories, allowing API calls to partner endpoints, or restricting outbound traffic to approved destinations.
| Direction | What it controls | Common example |
|---|---|---|
| Ingress | Traffic entering targeted VM instances | Allow HTTPS from internet users to web servers |
| Egress | Traffic leaving targeted VM instances | Allow app servers to reach external APIs or repositories |
A firewall rule is not just allow or deny. The most useful and most misunderstood parts are usually the rule priority and the target definition.
In Google Cloud, lower numeric values mean higher priority. If an allow rule has lower priority value than a deny rule, the allow rule can win for matching traffic. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
A rule can apply broadly or only to instances with selected network tags or service accounts. This is how teams make rules precise instead of exposing everything in a network.
Even a correctly targeted rule might not match the intended traffic if source or destination ranges are too broad, too narrow, or simply wrong.
Premium Google Cloud security design goes beyond simple VPC firewall rules. Logging and policy layers become important in larger, more governed environments.
Firewall Rules Logging helps teams see whether firewall rules allow or deny traffic, which is extremely useful during troubleshooting and audits. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Hierarchical firewall policies let organizations define firewall controls above the individual VPC level so policies can apply across folders and projects. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/hierarchical-firewall-policies?utm_source=chatgpt.com))
Network firewall policies provide another way to manage reusable and more centrally governed firewall logic across environments. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/network-firewall-policies?utm_source=chatgpt.com))
Firewall rules make much more sense when you connect them to actual application and operations scenarios.
A public load balancer and backend VM pattern still depends on the correct ingress access model to allow expected web traffic and deny unwanted traffic.
Database servers usually should not be open broadly. A precise ingress rule from the app tier or app service account is safer than wide subnet exposure.
Even with Cloud NAT configured, outbound firewall policy can still block package updates or API calls if the egress rule model is too restrictive.
Administrative access from on-premises networks through VPN or Interconnect depends on both routing and correct ingress rule matching.
Internal workloads often need carefully limited east-west traffic rules so only trusted services can talk to each other.
Some organizations use outbound firewall control to limit which external destinations sensitive workloads are allowed to reach.
Comparison helps engineers who already know another cloud platform and also improves discoverability for multi-cloud search.
| Feature | Google Cloud | AWS | Azure |
|---|---|---|---|
| Main firewall model | VPC firewall rules and policy layers | Security groups and NACLs | NSGs and Azure Firewall patterns |
| Stateful behavior | Stateful | Security groups are stateful | NSGs are stateful |
| Priority handling | Lower number = higher priority | Different rule evaluation models by service | Priority-based rule ordering in NSGs |
| Targeting model | Network tags and service accounts are important | Attachment to ENIs and resource groups | Attachment to subnet/NIC through NSGs |
| Enterprise policy layer | Hierarchical and network firewall policies | Different org/account-level governance patterns | Policy and central firewall models differ |
Good firewall design is about being explicit, narrow, and understandable rather than just making traffic work once.
Allow only the traffic that is needed, from the sources that are needed, to the targets that actually require it.
Use meaningful network tags or service-account-based targeting instead of broad rules that apply to everything in a network.
Priority numbers should not be random. Make it obvious why a rule is higher or lower precedence than surrounding rules.
Logging is especially useful for sensitive workloads, recurring incidents, audits, and rules that teams frequently debate.
Management traffic should not use the same broad rule patterns as user-facing application traffic.
In larger organizations, verify how VPC rules interact with hierarchical or network firewall policies so no hidden governance layer surprises the team.
These are the practical mistakes that repeatedly cause network outages, security gaps, or confusing diagnostics.
The firewall rule may be valid, but if the intended instance does not match the target tags or service account, the rule has no effect for that workload.
Teams often assume the newest rule wins or that allow always beats deny. In reality, priority and match logic decide the outcome. ([docs.cloud.google.com](https://docs.cloud.google.com/firewall/docs/firewalls?utm_source=chatgpt.com))
Large source ranges make rules easier to create but harder to secure and audit later.
Many teams focus only on ingress and forget that outbound restrictions or missing egress allowances can break application behavior.
Without logging, teams may spend too much time guessing whether the firewall is involved.
A valid route does not mean traffic is allowed, and a valid allow rule does not mean the route path exists.
Firewall troubleshooting works best when you validate the whole communication chain instead of only looking for a rule name that seems relevant.
Once firewall behavior makes sense, the next pages to study are the ones that explain route paths, dynamic routing, and outbound internet design in more detail.
Understand the larger network model firewall rules belong to.
See how subnet design and firewall targeting interact in real architectures.
Learn how path selection and firewall decisions work together.
Important when firewall logic intersects with hybrid route learning.
Useful for understanding outbound access together with egress rules.
Useful when firewall policies intersect with hybrid administrative or service access.