Prepare and test your skills
Prepare and test your skills
VPC Firewall Rules and Hierarchical Policies are the network controls that allow or deny ingress and egress traffic in Google Cloud. VPC firewall rules (opens in a new tab) attach to a single Virtual Private Cloud (VPC) network inside one project, while hierarchical firewall policies attach at the organization or folder level and apply to many projects and networks below. Traffic flows from sources outside the protected network to destinations inside it, and both layers are evaluated to create granular isolation for infrastructure and data.
A project-level rule protects only its own VPC network, so each VPC can have different ingress and egress controls while higher-level policies still enforce organization-wide limits. This two-layer design lets central teams block risky traffic everywhere and lets project teams open only the paths their workloads need. The result is consistent isolation across the organization without removing per-network control.
A VPC firewall rule in a VPC network is a project-level resource that is bound to one VPC network, such as a Private Service Connect network. The rule defines the project it belongs to and the network it protects, so traffic flowing from defined sources to destinations inside that network is checked against the rule. Because the rule lives with the network, each VPC keeps its own set of ingress and egress controls while hierarchical policies continue to apply from above.
Granular targeting limits which virtual machines send or receive the matched traffic. A rule can target workloads in three peer ways:
Traffic flows from the matched source to the tagged or identity-linked destination in the VPC, and only that flow is evaluated against the rule.
Direction, priority, and traffic matching in a VPC firewall rule decide when the rule applies and what action it takes. The example rule uses direction = "INGRESS" with priority = 1000, so the rule evaluates traffic flowing from an external source into targets in the VPC network. Lower priority numbers are evaluated first, so priority controls which rule wins when several rules could match the same flow.
Traffic matching in the example uses source_ranges set to the Private Service Connect NAT subnet CIDR, such as 10.1.0.0/16. Only traffic flowing from the NAT subnet to the Private Service Connect subnet matches the rule. The action uses an allow block with protocol = "all", which permits all protocols and ports for that matched ingress flow from the NAT sources to the protected subnet.
Firewall logging in a VPC firewall rule records connection information for auditing and troubleshooting. The example rule enables logging with log_config set to INCLUDE_ALL_METADATA, so each evaluated connection includes metadata about source, destination, and connection details. Logs flow from the firewall enforcement point to Cloud Logging, where administrators can review which NAT-to-subnet traffic was allowed or denied.
Logging does not change the allow or deny decision for the traffic flow. The firewall rule still permits or blocks the flow first, and logging only makes that isolation boundary observable across the organization.
Firewall rules for workload connectivity permit required application paths between servers and management components. For Site Recovery Manager (SRM), firewalls in the environment must permit communication between the SRM server and vCenter in the private cloud. Firewalls must also permit communication between the SRM servers at both the protected site and the recovery site.
Required SRM ports and protocols must remain open on those paths. Replication control traffic flows from each SRM server to its peer SRM server and from each SRM server to vCenter without being blocked, which keeps recovery coordination reachable while other traffic remains isolated.
Cloud Armor and Intrusion Detection Systems provide edge filtering and monitoring for internet-facing workloads. Google Cloud Armor (opens in a new tab) is an edge security service that protects deployments from distributed denial-of-service (DDoS) attacks and application attacks such as cross-site scripting (XSS) and SQL injection (SQLi). Traffic flows from the internet to the Google Cloud edge and then to protected workloads, and Google Cloud Armor filters that traffic at the edge far upstream of the workloads. Cloud Intrusion Detection System (Cloud IDS) complements Google Cloud Armor as an additional monitoring layer in a multi-layer security design.
Google Cloud Armor security policies are collections of rules that permit, deny, rate-limit, or redirect requests destined for a protected resource. Each rule contains a match condition and an action, and rules are applied in the order configured by the policy so the highest-priority matching rule takes effect for an incoming request. Only well-formed requests pass through the load-balancing proxies to backend services or backend buckets.
Match conditions in Google Cloud Armor can use Layer 3 through Layer 7 attributes for precise filtering:
Google Cloud Armor enforces these security policies at the Google Cloud edge, close to the traffic source and inside points of presence where external load balancing occurs. Unwanted traffic is blocked before it consumes backend capacity or enters VPC networks. Policies most often protect applications behind a load balancer, but they also protect VMs with external IP addresses and hybrid or multi-cloud backends reached through internet, hybrid, or serverless network endpoint groups.
DDoS protection in Google Cloud Armor is divided by network layer because network-layer floods and application-layer floods behave differently. Layer 3 and Layer 4 (L3/L4) volumetric and protocol-based attacks receive always-on automatic protection with real-time inline mitigation and no latency impact for applications behind load balancers. Layer 7 (L7) attacks such as HTTP floods require a user-configured security policy with proactive rules in place before the attack arrives.
| Protection layer | Activation | What stops the attack |
|---|---|---|
| L3/L4 volumetric and protocol attacks | Always on for protected load balancers | Automatic inline detection and mitigation by Google infrastructure |
| L7 application attacks and HTTP floods | Requires user-configured security policy | Custom filtering rules and Web Application Firewall (WAF) rules attached to backend services |
Google Cloud Armor automatically provides baseline DDoS protection for global external Application Load Balancers, classic Application Load Balancers, and external proxy Network Load Balancers, and it supports HTTP, HTTPS, HTTP/2, and QUIC. Enterprise subscribers gain added visibility through DDoS attack telemetry, Adaptive Protection for L7 anomalies, and advanced network DDoS monitoring for network load balancers, protocol forwarding, and VMs with public IP addresses.
Exam tip: L3/L4 DDoS mitigation is always on, while L7 HTTP-flood protection works only after you create a security policy and attach it to a backend service.
Web Application Firewall (WAF) filtering in Google Cloud Armor inspects HTTP and HTTPS requests for common web-attack patterns before they reach backend services. Preconfigured WAF rules package dozens of signatures from open-source industry standards into named rules, so one rule reference can evaluate many distinct attack signatures without manually defining each one. The preconfigured rules are based on the OWASP ModSecurity Core Rule Set (CRS) and support CRS versions 4.22, 3.3, and 3.0, with 4.22 recommended over lower versions.
Preconfigured WAF rules help mitigate OWASP Top 10 risks, including SQL injection, cross-site scripting, and command injection, and noisy or unnecessary signatures can be disabled through rule tuning. XML body parsing is not supported by preconfigured WAF rules. Managed rules provide a second WAF option that uses automatically updated threat signatures to address newly discovered CVEs and zero-day vulnerabilities with less manual configuration.
Google Cloud Armor Enterprise is the managed protection tier that adds L7 configurability, visibility, and learning-based defense on top of always-on L3/L4 protection. Google Threat Intelligence in Google Cloud Armor allows or blocks traffic to global external and classic Application Load Balancers based on continuously updated feeds, such as Tor exit nodes or VPN providers, using the evaluateThreatIntelligence() match expression in a security-policy rule. This lets a policy reject known-risk sources or allow only expected public-cloud ranges without maintaining the lists manually.
Adaptive Protection in Google Cloud Armor Enterprise defends backend services from L7 DDoS by analyzing traffic patterns and responding to sudden changes in those patterns. Adaptive Protection detects suspected attacks, alerts operators, and can suggest or automatically apply mitigating rules that can then be tuned, and it is enabled on a per-security-policy basis with an active Enterprise subscription. Advanced network DDoS protection extends always-on monitoring, alerting, targeted mitigation, and mitigation telemetry to Enterprise subscribers who use network load balancers, protocol forwarding, or VMs with public IP addresses.
Layered defense with intrusion detection combines edge blocking, reachability control, and inspection so no single control must stop every attack. Google Cloud Armor blocks unwanted traffic at the edge, while Cloud Next Generation Firewall with intrusion prevention, firewall threat intelligence, and Cloud IDS filter, inspect, and monitor threats at the network and application layers for analysis and prevention. The layers depend on each other because edge filtering reduces load, firewall policy controls reachability, and detection and inspection identify malicious activity that passes initial filters.
Traffic flows from the Internet through Cloud Armor edge filtering, an external load balancer, VPC firewall and hierarchical policy enforcement, and Cloud IDS plus NGFW inspection before reaching backend VMs in the VPC, with logs sent to Cloud Logging.
Traffic therefore moves through successive controls from the internet edge toward the VPC: Google Cloud Armor policy enforcement first, then load balancing and firewall evaluation, then deeper inspection and monitoring. Choosing this layered design prevents reliance on a single control when attacks span volumetric floods, web exploits, and evasive intrusions. Exposing applications through a load balancer or API gateway keeps that layered path consistent for Google Cloud, hybrid, and multi-cloud backends.
Attaching Google Cloud Armor protection means creating a security policy, adding rules, and binding the policy to the backend services that need it. The deployment follows an ordered workflow where each step depends on the prior step:
Google Cloud Armor security policies attach to the backend services of all external Application Load Balancers including classic, regional internal Application Load Balancer, global and classic proxy Network Load Balancers for TCP/SSL, and regional external passthrough Network Load Balancers for TCP/UDP. The backend service must use load-balancing scheme EXTERNAL, EXTERNAL_MANAGED, or INTERNAL_MANAGED with protocol HTTP, HTTPS, HTTP/2, UDP, TCP, SSL, or UNSPECIFIED, and policies work in Premium Tier or Standard Tier with optional QUIC. If multiple forwarding rules point to the same protected backend service, the same policy rules are enforced for traffic entering through each forwarding-rule address.
Identity-based access and private connectivity grants access based on verified user identity while keeping workloads off the public internet. Identity-Aware Proxy (IAP) (opens in a new tab) checks identity before traffic reaches internal resources, and private connectivity controls remove external IP addresses so resources stay inside the VPC network. Together they replace traditional perimeter approaches that rely on public IPs and VPNs alone.
Identity-Aware Proxy (IAP) is an application security control that manages access to applications running in App Engine standard environment, App Engine flexible environment, Compute Engine, and Google Kubernetes Engine (GKE). A user request flows from the internet to IAP first, IAP verifies the Google identity and IAM permission for that user, and only allowed traffic flows from IAP to the internal application or virtual machine (VM). For TCP use cases such as SSH, IAP performs TCP forwarding so an administrator can reach a VM that has no public IP without opening SSH to the world. Choose IAP when access should depend on who the user is rather than what network the user connects from.
Private connectivity without external IP addresses means Compute Engine VMs, GKE nodes, and managed data services communicate using internal VPC addresses and private paths to Google APIs. The VPC network depends on supporting controls to make this work while blocking public exposure, and the service depends on the subnet and instance configuration to allow internal-only communication. When these controls are combined, traffic flows from the client through IAP or the VPC to the private backend, and the public internet sits outside the trust boundary with no direct path to the workload.
Key controls that support this private model include:
Firewall policies that support identity-based access enforce the network boundary even when IAP enforces the identity boundary. The firewall policy applies to the consumer VPC network, and an ingress rule allows IAP-forwarded traffic while denying other external SSH attempts. To allow SSH through IAP, create a global network firewall policy, associate the policy with the consumer network, and add an ingress allow rule with priority 100 that allows TCP port 22 from source range 35.235.240.0/20.
The IPv4 range 35.235.240.0/20 contains all IP addresses that IAP uses for TCP forwarding, so the VM accepts SSH only when traffic flows from IAP to the VM. This keeps the VM without an external IP reachable for administration without exposing SSH to the internet.
Exam tip: Allow TCP port 22 from 35.235.240.0/20 to permit IAP TCP forwarding; do not open SSH to 0.0.0.0/0 when the VM has no external IP.
Hybrid private connectivity extends the same private model to on-premises networks using dedicated Google Cloud connectivity products. Traffic flows from the on-premises network through the selected connection to the VPC, and from the VPC to private workloads protected by IAP and firewall policies. The choice between products depends on cost and throughput needs.
| Option | Cost profile | Throughput profile |
|---|---|---|
| Cloud VPN | Lower-cost solution | Lower bandwidth requirements |
| Cloud Interconnect | Enterprise-grade connection | Higher throughput |
Choose Cloud VPN when lower cost and lower bandwidth are sufficient, and choose Cloud Interconnect when the workload needs an enterprise-grade link with higher throughput.
Virtual Private Cloud (VPC) firewall rules attach to a single VPC network inside one project, while hierarchical firewall policies attach at the organization or folder level and apply to many projects and networks below. Both layers are evaluated, which lets central teams block risky traffic everywhere while project teams open only the paths their workloads need.
Layer 3 and Layer 4 volumetric and protocol-based attacks receive always-on automatic protection for applications behind load balancers, while Layer 7 HTTP floods require a user-configured Google Cloud Armor security policy attached to a backend service. To stop Layer 7 attacks, create a security policy with proactive rules in place before the attack arrives and attach it to the backend services that need protection.
Create a global network firewall policy associated with the consumer VPC network and add an ingress allow rule with priority 100 that allows TCP port 22 from source range 35.235.240.0/20. That range contains all IP addresses that Identity-Aware Proxy (IAP) uses for TCP forwarding, so the virtual machine accepts SSH only when traffic flows from IAP and remains unreachable from the internet.
Google Cloud Armor Web Application Firewall (WAF) preconfigured rules inspect HTTP and HTTPS requests for common web-attack patterns before they reach backend services. They help mitigate OWASP Top 10 risks including SQL injection, cross-site scripting and command injection and are based on the OWASP ModSecurity Core Rule Set versions 4.22, 3.3 and 3.0 with 4.22 recommended.
An enterprise is deploying a mission-critical web application on Google Kubernetes Engine (GKE) and Compute Engine virtual machines behind a global external Application Load Balancer. The organization requires a multi-layered network security design that satisfies the following requirements:
Which combination of Google Cloud security services and configurations should you deploy?
Last updated