Question

Difficulty: MediumDeploying Virtual Private Cloud (VPC) Networks, Subnets, and Firewall Rules

A DevOps engineer is managing network security for a custom Virtual Private Cloud (VPC) network named `vpc-prod`. An existing ingress firewall rule named `allow-internal-web` with priority 1000 permits TCP traffic on port 8080 from the `10.0.0.0/8` IP range to VM instances tagged `web-frontend`. To address a security compliance finding, the engineer must explicitly block incoming TCP traffic on port 8080 originating from the `10.2.0.0/24` subnet while preserving access for all other subnets within `10.0.0.0/8`. Which `gcloud` command should the engineer execute?

  1. gcloud compute firewall-rules create block-subnet-web --network=vpc-prod --action=DENY --direction=INGRESS --priority=500 --source-ranges=10.2.0.0/24 --rules=tcp:8080 --target-tags=web-frontendAnswer
  2. B
    gcloud compute firewall-rules create block-subnet-web --network=vpc-prod --action=DENY --direction=INGRESS --priority=2000 --source-ranges=10.2.0.0/24 --rules=tcp:8080 --target-tags=web-frontend
  3. C
    Apply a project-level IAM Deny policy to the service account associated with subnet 10.2.0.0/24 to override the existing VPC firewall rule.
  4. D
    Assign the primitive Viewer role to instances in the 10.2.0.0/24 subnet to restrict network packet transmissions to port 8080.

Answer

Execute the command creating a DENY ingress rule on port 8080 from source range 10.2.0.0/24 targeted at web-frontend with priority 500.
Google Cloud VPC firewall rules are evaluated based on priority order where lower integer values denote higher evaluation precedence. Since the existing ALLOW rule has a priority of 1000, creating a DENY rule with priority 500 ensures that incoming packets from 10.2.0.0/24 matching port 8080 are matched and dropped first before reaching the priority 1000 allow rule.

Step-by-Step Solution

1
Understand GCP VPC firewall rule priority evaluation order.
GCP firewall rules are processed from lowest numerical priority value (0) to highest numerical priority value (65535). Once a matching rule is hit, evaluation stops.
To override an existing ALLOW rule with priority 1000, the DENY rule must have a priority number strictly less than 1000.
2
Evaluate the parameters required for the new firewall rule.
The rule must have `--action=DENY`, `--direction=INGRESS`, `--priority` < 1000 (e.g., 500), `--source-ranges=10.2.0.0/24`, `--rules=tcp:8080`, and `--target-tags=web-frontend`.
This ensures only packets from 10.2.0.0/24 intended for port 8080 on web-frontend instances are dropped.

Key Concept

VPC Firewall Priority Evaluation
Rate this question