# GCP Packet Mirroring Setup

Architecture

What's not supported


Assumptions


Requirements


Step 1: Create Target Compute Instances

|| If you already have target instances, skip this step and proceed to the next one.

  1. Navigate to VM instancesCreate Instance.

  2. Create a target VM instance:

    • Name: target-instance

    • Machine Type: Select a machine type, such as e2-standard .

    • Image: Debian 11 (or another suitable image).

  3. Under the Networking section:

    • Select the VPC network that the source instance is part of.

    • If necessary, choose the subnet that matches the source instance's subnet.

  4. Repeat these steps for target-instance-2.


Step 2: Create a Health Check

| The health check periodically probes the instances to confirm they are available and functioning as expected. || ror and collect traffic on the same network interface of a VM instance because doing this would cause a mirroring loop.

Navigate to Health ChecksCreate Health Check. 2. Set the following:

  1. Save the health check.


Step 3: Create an Instance Group

  1. Navigate to Instance GroupsCreate Instance Group.

  2. Configure the instance group:

    • Name: target-instance-group

    • Add the target-instance and target-instance-2 instances to the group.


Step 4: Create a Backend Service

| The backend service ensures that traffic is routed appropriately to the VM instances in your instance group. This is critical to ensure that only healthy instances serve incoming requests.

  1. Navigate to Load Balancing:

    • Go to Google Cloud Console.

    • Click on Network ServicesLoad BalancingBackend Services.

  2. Create a new backend service:

    • Name: my-service

    • Load Balancing Scheme: Internal

    • Protocol: TCP

  3. Add a health check:

    • Select the existing health check ( my-healthcheck) created in Step 2.

  4. Add a backend:

    • Under Backends, click Add Backend.

    • Choose Instance Group and select the target-instance-group created earlier.

    • Leave other settings as default.

  5. Save the backend service.


Step 5: Create a Forwarding Rule

| A forwarding rule determines how traffic is directed to your backend service. It specifies the IP address, port, and protocol (e.g., TCP or UDP) that the load balancer listens to.

  1. Navigate to Load Balancing Frontend Configuration:

    • From the Load Balancing page, click on the Frontend Configuration tab.

  2. Create a forwarding rule:

    • Name: my-ilb

    • Load Balancing Scheme: Internal

    • Network: my-network

    • Subnetwork: my-subnetwork

    • Protocol: TCP

    • Check Enable Mirroring Collector to use the forwarding rule for packet mirroring.

    • Select the backend service ( my-service) created earlier.

  3. Save the forwarding rule.


Step 6: Create Firewall Rules

Best Practice

|| Avoid using 0.0.0.0/0 unless absolutely necessary (e.g., for public-facing applications), always specify your trusted source IP or network range, allow mirrored traffic to target-backend)

  1. Create rules:


Step 7: Create Packet Mirroring

| Packet mirroring is used to copy traffic from the source instance and send it to the collector (the internal load balancer). This ensures traffic is distributed to both target instances for further analysis.

  1. Navigate to Packet Mirroring:

    • Go to Network SecurityPacket MirroringCreate Policy.

  2. Configure the policy:

    • Name: my-mirroring

    • Description: Add an optional description.

  3. Collector:

    • Select the forwarding rule ( my-ilb) created earlier.

  4. Mirrored Resources:

    • Subnetworks: Add my-subnetwork.

    • Instances: Add source-instance.

  5. Set Filters:

    • IP Protocol: TCP

    • CIDR Range: 0.0.0.0/0 (mirror all traffic).

    • Direction: BOTH (ingress and egress).

Why BOTH?

|| Captures the full context of a network interaction (requests and responses).

  1. Save the packet mirroring policy.


What next? Setup Astra Packet Processor