Firewall Rules

Allowing Traffic

VPC firewall rules control which traffic reaches VMs. Rules can target VMs by network tag or service account.

Example

Allow HTTP to VMs tagged http-server:

gcloud compute firewall-rules create allow-http \
  --network=default --direction=INGRESS \
  --action=ALLOW --rules=tcp:80 \
  --source-ranges=0.0.0.0/0 --target-tags=http-server

Example output

NAME        NETWORK  DIRECTION  PRIORITY  ALLOW   DENY  DISABLED
allow-http  default  INGRESS    1000      tcp:80        False

Note: Never open SSH (port 22) to 0.0.0.0/0. Use IAP TCP forwarding (gcloud compute ssh --tunnel-through-iap) so VMs need no public SSH access.