Zum Inhalt springen
Skillpedia
Deployment & Cloud (DevOps)35k · #8044

implementing-gcp-vpc-firewall-rules

Was er macht

Dieses Tool hilft dir, die Firewall-Regeln deines Google Cloud (GCP) Netzwerks einzurichten und zu überprüfen. Es sorgt dafür, dass nur erlaubter Datenverkehr in dein Netzwerk hinein- oder aus ihm herauskommt, und schützt so deine Daten.

Wann du ihn nutzt

  • ✓Wenn du ein neues Netzwerk in GCP einrichtest.
  • ✓Wenn du bestehende Sicherheitsregeln überprüfst.
  • ✓Wenn du auf Sicherheitswarnungen wegen unbefugtem Zugriff reagierst.

Link zum Skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-gcp-vpc-firewall-rules/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/implementing-gcp-vpc-firewall-rules/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Richte eine Regel ein, die SSH-Zugriff nur von einer bestimmten IP-Adresse auf Server mit dem Tag 'web-server' erlaubt.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Das Tool nutzt Google-Cloud-Befehle (gcloud), um Firewall-Regeln anzuzeigen, anzulegen und zu ändern. Du legst fest, welcher Datenverkehr erlaubt oder blockiert wird, woher er kommt und wohin er geht.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

Implementing GCP VPC Firewall Rules

When to Use

  • When deploying new GCP workloads that require network-level access controls
  • When auditing existing firewall configurations for overly permissive rules
  • When implementing zero trust network segmentation within GCP VPC networks
  • When responding to Security Command Center findings about open firewall rules
  • When building hierarchical firewall policies across a GCP organization

Do not use for application-layer filtering (use Cloud Armor WAF), for DNS-based filtering (use Cloud DNS response policies), or for VPN/interconnect traffic filtering without understanding that VPC firewall rules apply to traffic within the VPC.

Prerequisites

  • GCP project with Compute Engine API enabled
  • IAM roles: roles/compute.securityAdmin for firewall management, roles/compute.networkViewer for auditing
  • Organization Admin role for hierarchical firewall policies
  • gcloud CLI authenticated with appropriate permissions
  • VPC Flow Logs enabled on target subnets for monitoring

Workflow

Step 1: Audit Existing Firewall Rules for Security Gaps

Enumerate all firewall rules and identify overly permissive configurations.

# List all firewall rules in the project
gcloud compute firewall-rules list \
  --format="table(name, network, direction, priority, allowed[].map().firewall_rule().list():label=ALLOWED, sourceRanges, targetTags)"

# Find rules allowing all traffic from 0.0.0.0/0
gcloud compute firewall-rules list \
  --filter="direction=INGRESS AND sourceRanges=0.0.0.0/0" \
  --format="table(name, network, allowed, priority, targetTags)" \
  --sort-by=priority

# Find rules allowing all protocols and ports
gcloud compute firewall-rules list \
  --filter="direction=INGRESS AND allowed[].IPProtocol=all" \
  --format="table(name, network, sourceRanges, targetTags)"

# Find rules with SSH (22) or RDP (3389) open to the internet
gcloud compute firewall-rules list \
  --filter="direction=INGRESS AND sourceRanges=0.0.0.0/0 AND (allowed[].ports=22 OR allowed[].ports=3389)" \
  --format="table(name, network, allowed, sourceRanges)"

# Check for disabled rules
gcloud compute firewall-rules list \
  --filter="disabled=true" \
  --format="table(name, network, direction)"

Step 2: Create Restrictive Ingress Firewall Rules

Implement least-privilege ingress rules using network tags and service accounts for targeting.

# Create rule allowing HTTPS from the internet to web servers only
gcloud compute firewall-rules create allow-https-web \
  --network=production-vpc \
  --direction=INGRESS \
  --action=ALLOW \
  --rules=tcp:443 \
  --source-ranges=0.0.0.0/0 \
  --target-tags=web-server \
  --priority=1000 \
  --description="Allow HTTPS to web servers from internet"

# Create rule allowing SSH only from bastion host subnet
gcloud compute firewall-rules create allow-ssh-bastion \
  --network=production-vpc \
  --direction=INGRESS \
  --action=ALLOW \
  --rules=tcp:22 \
  --source-ranges=10.0.1.0/24 \
  --target-tags=ssh-allowed \
  --priority=1000 \
  --description="Allow SSH only from bastion subnet"

# Create rule allowing internal communication between app tiers
gcloud compute firewall-rules create allow-app-to-db \
  --network=production-vpc \
  --direction=INGRESS \
  --action=ALLOW \
  --rules=tcp:5432 \
  --source-tags=app-server \
  --target-tags=db-server \
  --priority=1000 \
  --description="Allow PostgreSQL from app tier to database tier"

# Create service-account-based rule (more secure than tags)
gcloud compute firewall-rules create allow-api-internal \
  --network=production-vpc \
  --direction=INGRESS \
  --action=ALLOW \
  --rules=tcp:8080 \
  --source-service-accounts=api-client@project.iam.gserviceaccount.com \
  --target-service-accounts=api-server@project.iam.gserviceaccount.com \
  --priority=1000

Step 3: Implement Egress Restrictions

Configure egress firewall rules to control outbound traffic and prevent data exfiltration.

# Deny all egress by default (low priority)
gcloud compute firewall-rules create deny-all-egress \
  --network=production-vpc \
  --direction=EGRESS \
  --action=DENY \
  --rules=all \
  --destination-ranges=0.0.0.0/0 \
  --priority=65534 \
  --description="Default deny all egress traffic"

# Allow egress to Google APIs via restricted VIP
gcloud compute firewall-rules create allow-google-apis \
  --network=production-vpc \
  --direction=EGRESS \
  --action=ALLOW \
  --rules=tcp:443 \

…
Häufige Fragen

Was sind Firewall-Regeln?

Sie funktionieren wie digitale Türsteher. Anhand der Regeln, die du festlegst, kontrollieren sie, wer in dein virtuelles Netzwerk in der Cloud hinein- oder herauskommt.

Was bedeuten 'Ingress' und 'Egress'?

'Ingress' ist eingehender Datenverkehr, also alles, was in dein Netzwerk hineinkommt. 'Egress' ist ausgehender Datenverkehr, also alles, was aus deinem Netzwerk hinausgeht.

Kann ich damit bestimmte Websites blockieren?

Nicht direkt. Dieses Tool konzentriert sich auf Netzwerkregeln. Um Websites zu blockieren, brauchst du andere Werkzeuge wie Cloud Armor oder DNS.

Details

Originalbeschreibung des Autors

Implements and audits GCP VPC firewall rules using gcloud, covering auditing overly permissive rules, creating restrictive ingress/egress rules, hierarchical firewall policies, and monitoring rule effectiveness with VPC Flow Logs. Use when deploying GCP workloads needing network access controls, auditing firewall configs, or responding to Security Command Center findings; not for Cloud Armor or DN

repo: mukul975/Anthropic-Cybersecurity-Skills

Beliebtheit

GitHub-Sterne
35k
Platz im Ranking
#8044
Lizenz
Apache-2.0
Aktualisiert
31.8.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills