This document provides a comprehensive guide to leveraging the Network Security Integration (NSI) mirroring mode with Palo Alto Networks Software Firewalls. The primary objective is to enable organizations to perform a Security Lifecycle Review (SLR) on their existing Google Cloud environments.
Key Objectives:
-
Deploy with NSI Mirroring Mode: Implement an out-of-band inspection model that mirrors network traffic to Palo Alto Networks Software Firewalls. This deployment method ensures zero disruption to live traffic and requires no architectural changes to the existing customer environment, allowing for a seamless integration with minimum effort.
-
Identify Security Risks and Posture: Utilize the advanced threat detection capabilities of Palo Alto Networks to analyze the mirrored traffic. This process generates a Security Lifecycle Report (SLR) that provides deep visibility into the current security posture, identifying potential vulnerabilities, malware, data exfiltration risks, and other cyber threats present in the network.
-
Transition to Production with NSI Intercept Mode: Armed with the insights from the SLR, organizations can effectively plan and execute a transition to the NSI in-line (intercept) mode. This production-ready configuration actively steers traffic through the firewalls, enforcing security policies to block threats and protect customer resources, thereby completing the journey from visibility to active protection. For the details steps, you can refer to Deploy NSI intercept mode
This tutorial details the deployment of these models within the Network Security Integration (NSI) framework. NSI enables you to gain visibility and security for your VPC network traffic, without requiring any changes to your network infrastructure.
The functionality of each model is summarized as follows:
| Model | Description |
|---|---|
| Out-of-Band | Uses packet mirroring to forward a copy of network traffic to Software Firewalls for out-of-band inspection. Traffic is mirrored to your software firewalls by creating mirroring rules within your network firewall policy. |
| In-line | Uses packet intercept to steer network traffic to Software Firewalls for in-line inspection. Traffic is steered to your software firewalls by creating firewall rules within your network firewall policy. |
This tutorial is intended for network administrators, solution architects, and security professionals who are familiar with Compute Engine and Virtual Private Cloud (VPC) networking.
NSI follows a producer-consumer model, where the consumer consumes services provided by the producer. The producer contains the cloud infrastructure responsible for inspecting network traffic, while the consumer environment contains the cloud resources that require inspection.
The producer creates firewalls which serve as the backend service for an internal load balancer. For each zone requiring traffic inspection, the producer creates a forwarding rule, and links it to an intercept or mirroring deployment which is a zone-based resource. These are consolidated into an deployment group, which is then made accessible to the consumer.
| Component | Description |
|---|---|
| Load Balancer | An internal network load balancer that distributes traffic to the NGFWs. |
| Deployments | A zonal resource that acts as a backend of the load balancer, providing network inspection on traffic from the consumer. |
| Deployment Group | A collection of intercept or mirroring deployments that are set up across multiple zones within the same project. It represents the firewalls as a service that consumers reference. |
| Instance Group | A managed or unmanaged instance group that contains the firewalls which enable horizontal scaling. |
The consumer creates an intercept or mirroring endpoint group corresponding to the producer's deployment group. Then, the consumer associates the endpoint group with VPC networks requiring inspection.
Finally, the consumer creates a network firewall policy with rules that use a security profile group as their action. Traffic matching these rules is intercepted or mirrored to the producer for inspection.
| Component | Description |
|---|---|
| Endpoint Group | A project-level resource that directly corresponds to a producer's deployment group. This group can be associated with multiple VPC networks. |
| Endpoint Group Association | Associates the endpoint group to consumer VPCs. |
| Firewall Rules | Exists within Network Firewall Policies and select traffic to be intercepted or mirrored for inspection by the producer. |
| Security Profiles | Can be type intercept or mirroring and are set as the action within firewall rules. |
The network firewall policy associated with the consumer-vpc contains two rules, each specifying a security profile group as their action. When traffic matches either rule, the traffic is encapsulated to the producer for inspection.
| Network Firewall Policy | ||||
|---|---|---|---|---|
| PRIORITY | DIRECTION | SOURCE | DESTINATION | ACTION |
10 |
Egress |
0.0.0.0/8 |
0.0.0.0/0 |
apply-security-profile |
11 |
Ingress |
0.0.0.0/0 |
0.0.0.0/8 |
apply-security-profile |
Note
In the out-of-band model, traffic would be mirrored to the firewalls instead of redirected.
- The
web-vmmakes a request to the internet. The request is evaluated against the rules within the Network Firewall Policy associated with theconsumer-vpc. - The request matches the
EGRESSrule (priority:10) that specifies a security profile group as its action. - The request is then encapsulated and mirrored through the
endpoint associationto the producer environment. - Within the producer environment, the
intercept deployment groupmirror the traffic to theintercept deploymentlocated in the same zone as theweb-vm. - The internal load balancer forward the traffic to an available firewall for deep packet inspection.
- If the firewall permits the traffic, it is returned to the
web-vmvia the consumer'sendpoint association. (This is only for In-Line mode, for out-of-band mode this will not happen, the original traffic will flow as usual) - The local route table of the
consumer-vpcroutes traffic to the internet via the Cloud NAT. - The session is established with the internet destination and is continuously monitored by the firewall.
-
Two Google Cloud projects (Producer and Consumer).
-
Access to Cloud Shell.
-
The following IAM Roles:
Ability Scope Roles Create firewall endpoints, endpoint associations, security profiles, and network firewall policies. Organization compute.networkAdmincompute.networkUsercompute.networkViewerCreate global network firewall policies and firewall rules for VPC networks. Project compute.securityAdmincompute.networkAdmincompute.networkViewercompute.viewercompute.instanceAdmin
In the producer directory, use the terraform plan to create the producer's VPCs, instance template, instance group, internal load balancer, intercept deployment, and intercept deployment group.
Tip
In production environments, it is recommended to deploy the producer resources to a dedicated project. This ensures the security services are managed independently of the consumer.
Caution
It is required to make your cloudshell git support large file download, run below command to install git lfs before you start to clone the source code.
sudo apt install git-lfs
And ensure you enabled the necessary API services in your Producer project. Run below commands before you start the terraform build.
gcloud services enable \
cloudresourcemanager.googleapis.com \
compute.googleapis.com \
iam.googleapis.com \
networksecurity.googleapis.com
-
In Cloud Shell, clone the repository change to the
producerdirectory.git clone https://github.com/PaloAltoNetworks/google-cloud-nsi-security-lifecycle.git cd google-cloud-nsi-security-lifecycle/producer -
Create a
terraform.tfvars.cp terraform.tfvars.example terraform.tfvars -
Edit
terraform.tfvarsby setting values for the following variables:Key Value Default project_idThe Google Cloud project ID of the producer environment. nullmgmt_allow_ipsA list of IPv4 addresses which have access to the firewall's mgmt interface. ["0.0.0.0/0"]mgmt_public_ipIf true, the management address will have a public IP assigned to it. falseregionThe region to deploy the consumer resources. us-west1image_nameThe firewall image to deploy. vmseries-flex-bundle2-1126mirroring_modeIf true, configures the forwarding rule for packet mirroring. If false, configures it for in-band traffic. true
Caution
It is recommended to set mgmt_public_ip to false in production environments.
Tip
For image_name, a full list of public images can be found with this command:
gcloud compute images list --project paloaltonetworksgcp-public --no-standard-images
All NSI deployments require PAN-OS 11.2.x or greater.
Note
If you are using BYOL image (i.e. vmseries-flex-byol-*), the license can be applied during or after deployment. To license during deployment, add your authcode to bootstrap_files/authcodes. See Bootstrap Methods for more information.
-
Initialize and apply the terraform plan.
terraform init terraform applyEnter
yesto apply the plan. -
After the apply completes, terraform displays the following message:
export PRODUCER_PROJECT=your-project-id export DATA_VPC=nsi-data export DATA_SUBNET=us-west1-data export REGION=us-west1 export ZONE=us-west1-a export BACKEND_SERVICE=https://www.googleapis.com/compute/v1/projects/your-project-id/regions/us-west1/backendServices/panw-nsi-lb
Important
The init-cfg.txt includes plugin-op-commands=geneve-inspect:enable bootstrap parameter, allowing firewalls to handle GENEVE encapsulated traffic forwarded via packet intercept or packet mirror.
If this is not configured, packet intercept/mirror traffic will be dropped.
Note
This is not required if assessment customer existing environmenat, and this consumer environment is just for the demo purpose.
In the consumer directory, use the terraform plan to create a consumer environment. The terraform plan creates a VPC (consumer-vpc) , two debian VMs (client-vm & web-vm), and a GKE cluster (cluster1) (optinal).
Note
If you already have an existing consumer environment, skip to Create Intercept Endpoint Group.
Set to Consumer project
export CONSUMER_PROJECT="<your consumer project>" ### replace with consumer project
Switch to Consumer project
gcloud config set project $CONSUMER_PROJECT
And ensure you enabled the necessary API services in your Comsumer project. Run below commands before you start the terraform build.
gcloud services enable \
cloudresourcemanager.googleapis.com \
compute.googleapis.com \
iam.googleapis.com \
networksecurity.googleapis.com \
secretmanager.googleapis.com
-
In Cloud Shell, change to the
consumerdirectory.cd cd google-cloud-nsi-security-lifecycle/consumer -
Create a
terraform.tfvarscp terraform.tfvars.example terraform.tfvars -
Edit
terraform.tfvarsby setting values for the following variables:Variable Description Default project_idThe project ID of the consumer environment. nullmgmt_allowed_ipsA list of IPv4 addresses that can access the VMs on TCP:80,22.["0.0.0.0/0"]regionThe region to deploy the consumer resources. us-west1create_gkeWhether to create the GKE cluster. false -
Initialize and apply the terraform plan.
terraform init terraform applyEnter
yesto apply the plan. -
After the apply completes, terraform displays the following message:
export CONSUMER_PROJECT=your-project-id export CONSUMER_VPC=consumer-vpc export REGION=us-west1 export ZONE=us-west1-a export CLIENT_VM=client-vm export CLUSTER=cluster1 export ORG_ID=$(gcloud projects describe your-project-id --format=json | jq -r '.parent.id')
Note
For the Security Lifecycle Assessment, we will use mirror mode of the NSI. We will not block any traffic, the purpose is to understand if there are any existing security issues or risks.
-
Navigate to Network Security -> Deployment groups, and select "Create deployment group." Configure the settings as follows:
-
Select "Create mirroring deployment" and configure the settings:
- Name:
nsi-demo-deployment - Region:
us-west1 - Zone:
us-west1-a - Load balancer:
nsi-panw-lb - Forwarding rule:
nsi-panw-lb-rule(The rule created by terraform, it should be auto-selected after you selected the load balancer)
Note: The preceding steps may be replicated to create multiple intercept deployments for individual zones, should the protection of resources across various zones be required. For the purpose of this demonstration, interception is enabled exclusively for resources within the
us-west1-azone.
- Name:
-
Select "Create" to proceed.
After a short waiting period, the intercept deployment's status should transition to "Active." This concludes the configuration within the Producer project. The process now continues with the Consumer project, where the protected resources reside.On the Consumer ProjectCreation of Intercept Endpoint & Endpoint Group
-
Navigate to Network Security -> Endpoint groups, and select "Create endpoint group." Configure the settings as follows:
- Name:
nsi-demo-epg - Purpose: NSI Out-of-Band (For mirroring)
- Name:
-
For the Deployment group, select Manual Entry, and input the following information:
- Project ID:
<Your Producer project ID> - Deployment group name:
nsi-demo-deployment-group(The deployment group name created previously in the producer project)
- Project ID:
-
Select "Continue." In the "Associations" section, select "Add endpoint group association." Configure the settings as follows:
- Project:
<the name of the consumer project>(Ensure that the Compute Engine API and Network Security API are enabled) - Network:
consumer-vpc(The VPC containing the resources to be protected; this VPC was pre-created by the Terraform template)
- Project:
-
Select "Done" upon completion.
-
Select "Create" to provision the endpoint group.
-
Allow a brief period for the configuration to take effect, and the endpoint group's status should indicate "Active."Creation of Security Profile and Security Profile Group
Note: Completion of the following steps requires the Org-level permissions outlined at the beginning of the documentation.
-
Navigate to Networks Security -> Common components -> Security profiles, and select "Create Security profile." Configure the settings as follows:
- Name:
nsi-demo-profile - Purpose: NSI Out-of-Band
- Traffic directed to:
- Project:
<Consumer project ID> - Endpoint group:
nsi-demo-epg(The endpoint group configured previously in the consumer project)
- Project:
- Name:
-
Select "Create."
-
Select the "Security profile groups" tab, and select "Create profile group."
-
Configure the settings as follows:
- Name:
nsi-demo-profile-group - Purpose: NIS Out-of-Band
- Custom mirroring profile:
nsi-demo-profile(The security profile created in the preceding step)
- Name:
-
Switch to the Consumer project, navigate to Cloud NGFW -> Firewall policies, and select "Create firewall policy." Configure the settings as follows:
- Policy Name:
nsi-demo-consumer-policy - Policy Type: VPC policy
- Deployment scope: Global
- Policy Name:
-
Select "Continue."
-
In the Add rules section, we don't need to configure that, as we are doing mirroring traffic not intercept, just click "Continue"
-
In the Add mirroring rules Select "Create mirroring rule." (Two mirroring rules are required: one for egress to destination
0.0.0.0/0and one for ingress from source0.0.0.0/0, with the action set to apply the security profile group created for NSI Out-of-Band.)- Ingress rule:
- Priority: 10
- Direction of traffic: Ingress
- Action on match: Mirror
- Security profile group:
nsi-demo-profile-group
- Security profile group:
- Source filters: IPv4:
0.0.0.0/0 - All other settings should remain at their default values.
- Egress rule:
- Priority: 11
- Direction of traffic: Egress
- Action on match: Mirror
- Security profile group:
nsi-demo-profile-group
- Security profile group:
- Destination filters: IPv4:
0.0.0.0/0 - All other settings should remain at their default values.
- Ingress rule:
-
-
Click "Continue" before moving onto Step 3 “Associate policy with networks”.

-
In the Associate policy with networks section, select "Associate." Select the
consumer-vpcand select "Associate."

4. Select "Create."
- Setup the access to the firewall managment console
- Switch to Producer Project
export PRODUCER_PROJECT="<your producer project>" ###replace with producer project gcloud config set project $PRODUCER_PROJECT - In Your local laptop, get the firewall’s management IP address and build the access to the firewall through the bastion host and IAP-Tunnel. Notice: The local proxy port is set to 8081 by default, if you want to use another port, you can update the script below in last line:
- Switch to Producer Project
Caution
Please run the script below on your local laptop with the gcloud CLI installed. Ensure that the terminal remains open until you have completed accessing the firewall, as the proxy tunnel will terminate if the terminal session is closed.
```
output=$(gcloud compute instances list --filter="name:bastion" --project=function-receiver --format="value(name,zone)")
export BASTION_NAME=$(echo "$output" | awk '{print $1}')
export BASTION_ZONE=$(echo "$output" | awk '{print $2}')
export MGMT_ADDRESS=$(gcloud compute instances list \
--filter="name:gcs-temp-panw-firewall" \
--format="value(networkInterfaces[0].networkIP)")
gcloud compute ssh $BASTION_NAME \
--tunnel-through-iap \
--zone=$BASTION_ZONE \
-- -N -L 8081:$MGMT_ADDRESS:443
```
-
Access the web management console using your browser, if you see a warning for invalid certificate, should be good, as in the demo environment it's using self-signed certifcate, just click "proceed" (If you have multiple FW instances in the instance group, you would need to repeat below steps to get all the logs for individual FW instance)
https://127.0.0.1:8081Username:
adminPassword:
PaloAlto@123
Note
It is not a good practise to hardcode password in the NGFW instance, here is just for demo purpose and ease the steps of configuration. Highly recommand you set complex password during the intial setup of the firewall instance.
-
Download the NGFW Stats Dump file (only 7-days traffic available through the UI). Navigate to Device ->Support -> Stats Dump File, click "Generate Stats Dump File"
-
(Optional)Your can generate longer period of data (if you need more than 7 days logs) from the VM-Series using CLI: (you would need to host a SCP server in your environemt to export the log)
scp export stats-dump start-time equal <YYYY/MM/DD@HH:MM:SS> end-time equal <YYYY/MM/DD@HH:MM:SS> to <username>@<scp-server-ip>:<file-path>
Note
Please check back in 7 days (by default, or the x days you like using the scp to export more logs as described in the previous steps), and download the NGFW Stats Dump file. Because if you continue and generate the report now, it would have enough log amount at this moment.
-
If you don't have an existing account, register at Link.
-
Access the CSP (Customer support portal) at URL: https://support.paloaltonetworks.com/Support/Index
After login with your Navigate to Resources -> Security Lifecycle Review
Navigate to Network Security -> Cloud NGFW -> Firewall policies.
Locate the Network firewall policy created by name.
-
Remove the firewall policy associations.
-
Delete the Firewall policy.
-
Delete the Security Profile Group and Security Profile (Org-level permission is required).
-
Navigate to Network Security -> Cloud NSI -> Endpoint groups. Select the created endpoint group, select the association created, and delete it. (The association must be removed prior to deleting the endpoint group.) Subsequently, delete the endpoint group.
-
Run
terraform destroyfrom theconsumerdirectory.cd cd google-cloud-nsi-security-lifecycle/consumer terraform destroy -
Enter
yesto delete all consumer resources.
-
Navigate to Network Security -> Cloud NSI -> Deployment groups. Select the created deployment group. Select the intercept deployment endpoint, and delete it.
-
The deployment group may now be deleted.
-
Run
terraform destroyfrom the/producerdirectory.cd cd google-cloud-nsi-security-lifecycle/producer terraform destroy -
Enter
yesto delete all producer resources.















