Skip to content

About

Terraform tutorial detailing how to deploy Active/Passive VM-Series with session sync in Google Cloud.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

7 stars

Watchers

5 watching

Forks

Repository files navigation

VM-Series Active/Passive HA on Google Cloud

Palo Alto Networks + Google Cloud Tutorials

This tutorial creates a pair of Active/Passive VM-Series firewalls on Google Cloud. This deployment model provides solutions for the following key use-cases:

  • Maintaining session continuity through stateful failover between the VM-Series firewalls.
  • Terminating IPsec tunnels directly to the VM-Series firewall through the external load balancer.
  • Preserving the original client IP address for internet inbound traffic to internal applications protected by the VM-Series firewalls.

The autoscale architecture is recommended in most use-cases. Please see VM-Series on Google Cloud for more information on VM-Series deployment models.

Architecture

In this model, each VM-Series firewall belongs to an unmanaged instance group. Only the primary VM-Series firewall receives network traffic from Google Cloud load balancers. The health check configured on the load balancers determines the HA state of the primary VM-Series firewall. If the health check fails on the primary VM-Series firewall, the load balancers send all traffic, including existing sessions, to the secondary VM-Series firewall. At that point, the secondary VM-Series firewall becomes the primary firewall.

Note

The VM-Series firewalls synchronize session state over the HA2 interface. During a failure event, the connection tracking policy on the load balancers moves existing connections to the new active firewall, which already has their session state.

Overview Diagram

Resources
VM-Series
  • 2 x VM-Series are deployed to separate zones within a region.
  • Each firewall belongs to an unmanaged instance group.
  • Each instance group is a backend of both the internal and external load balancers.
External LB An external pass-through load balancer with two forwarding rules:
  • Rule 1: Forwards internet inbound traffic to the VM-Series untrust interface.
  • Rule 2: Serves as the source NAT address for outbound internet traffic, so return traffic comes back through the load balancer to the active firewall.
Internal LB An internal pass-through load balancer with a single forwarding rule. Traffic from workload networks uses the load balancer's forwarding rule as the next hop within their VPC route table.
Policy-based route Sends traffic between the test VMs in the trust subnet (vm1 and vm2) to the internal load balancer, so the VM-Series inspects it.
VPC Networks
Mgmt VPC Contains the VM-Series MGT interfaces. This interface also serves as the HA1 interface.
HA2 VPC Contains the VM-Series HA2 interfaces.
Untrust VPC Serves as the internet gateway for resources within the trust VPC.
Trust VPC Contains the workloads protected by the VM-Series. This VPC can also serve as a hub network with multiple VPCs peered to it.

Important

After deployment, the load balancer's health checks will only pass on the active VM-Series firewall. This is because the dataplane of the passive firewall is inactive and is unable to pass the health checks. During a failure event, the passive firewall becomes active and the health checks will pass.

Prepare for deployment

  1. In Cloud Shell, enable the required APIs, generate an SSH key, and clone the repository.

    gcloud services enable compute.googleapis.com networkconnectivity.googleapis.com
    ssh-keygen -f ~/.ssh/panw-tutorial -t rsa
    git clone https://github.com/PaloAltoNetworks/google-cloud-vmseries-ha-tutorial
    cd google-cloud-vmseries-ha-tutorial
    
  2. Create a terraform.tfvars file.

    cp terraform.tfvars.example terraform.tfvars
    
  3. Edit the terraform.tfvars file and set values for the following variables:

    Variable Description
    project_id Set to your Google Cloud deployment project.
    region The Google Cloud region for the deployment.
    public_key_path Set to the public key you created previously (~/.ssh/panw-tutorial.pub).
    mgmt_allow_ips Set to a list of IPv4 ranges that can access the VM-Series management interface.
    mgmt_public_ip If true, set a public IP
    create_workload_vms (Optional) Set to false to skip creating the workload VMs used for testing.
    vmseries_image_name (Optional) Defines the VM-Series image to deploy. A full list of images can be found here.
  4. (Optional) If you are using a BYOL image (e.g. vmseries-flex-byol-*), the license can be applied during deployment by adding your VM-Series authcode to bootstrap_files/authcodes.

  5. Save your terraform.tfvars file.

Deployment

When no further changes are necessary in the configuration, deploy the resources:

  1. Initialize and apply the Terraform plan.

    terraform init
    terraform apply
    
  2. Enter yes to start the deployment.

  3. After all the resources are created, Terraform displays the following message:

    Apply complete! Resources: 72 added, 0 changed, 0 destroyed.
    
    Outputs:
    
    ATTENTION = "The firewalls take ~10 minutes to boot after the apply completes. Wait before logging in or testing."
    

Caution

After the apply completes, it may take ~10 minutes for the VM-Series to become available.


Access the Active VM-Series firewall

Set a password for the admin user on the active firewall. The password syncs to the standby firewall when you commit.

  1. In Cloud Shell, save both firewalls' management addresses and SSH into the active firewall

    read ACTIVE_FW_IP STANDBY_FW_IP <<< "$(gcloud compute instances list \
        --filter='tags.items=(panw-tutorial) AND name~vmseries' \
        --sort-by=name \
        --format='value(networkInterfaces[1].accessConfigs[0].natIP, networkInterfaces[1].networkIP)' \
        | awk '{printf "%s ", $1}')"
    
    ssh admin@$ACTIVE_FW_IP -i ~/.ssh/panw-tutorial
    

Tip

If the management interfaces do not have public addresses, the variables are set to their private addresses. Run the remaining steps from a network that can reach the management VPC.

  1. Set a password for the admin user. Enter the password twice when prompted.

    configure
    set mgt-config users admin password
    
  2. Commit the changes.

    commit
    
  3. Once the commit completes, enter exit twice.

  4. Retrieve the URL of each firewall, then log in to both as admin. Keep both tabs open for the failover test.

    echo https://$ACTIVE_FW_IP
    echo https://$STANDBY_FW_IP
    

Test the Deployment

You can now test the deployment, including failover, by accessing vm1 that resides in the trust VPC network. All of the vm1 traffic is routed directly through the VM-Series HA pair.

Access the Workload VM

  1. In Cloud Shell, save the address of the external load balancer's inbound forwarding rule to an environment variable.

    export EXTERNAL_LB_IP=$(gcloud compute forwarding-rules list \
        --filter="name~extlb-inbound" \
        --format="value(IPAddress)")
    
    echo http://$EXTERNAL_LB_IP
    
  2. Open the URL from the previous step in a web browser to access the web service on vm1 through the VM-Series firewall.

  3. Use the same address to open an SSH session through the VM-Series to vm1.

    ssh paloalto@$EXTERNAL_LB_IP -i ~/.ssh/panw-tutorial
    
  4. On vm1, check the egress address. The output is the address of the outbound forwarding rule on the external load balancer.

    curl https://icanhazip.com
    

Note

Egress traffic from vm1 is routed to the internal load balancer's forwarding rule. The VM-Series inspects and translates the request to the outbound forwarding rule on the external load balancer.

  1. On vm1, open an interactive session to vm2 in the same subnet. A policy-based route sends this traffic through the VM-Series.

    create-sessions
    
  2. Type hello and press Enter. vm2 replies with the session number and the time the session opened.

     Connecting to vm2 (10.0.2.6) through the VM-Series. Type a message and press Enter. Ctrl+C to quit.
     vm2: connected. This is session 1, opened 17:20:01.
     hello
     vm2: received "hello" | session 1, opened 17:20:01 | message 1

Important

Leave this session open for the rest of the test.

Test failover

  1. In each firewall's web interface, check the HA status in the bottom right corner. The standby firewall shows as Passive.

    Active firewall
    Standby firewall
  2. On the active firewall, go to Device → High Availability → Operational Commands.

  3. Click Suspend local device for high availability, then click OK. The standby firewall takes over as active.

  4. Return to your SSH session on vm1. It is still connected, which shows that the session failed over to the new active firewall.

  5. In the same session, type after failover and press Enter. The reply can take a few seconds while the load balancers switch to the new active firewall.

     after failover
     vm2: received "after failover" | session 1, opened 17:20:01 | message 2

Note

The reply still shows session 1, so the session to vm2 also failed over without reconnecting. If no reply arrives within a minute, the session did not fail over.

  1. On the suspended firewall, go to Device → High Availability → Operational Commands and click Make local device functional. It becomes the active firewall again.

(Optional) Onboard internet applications

To publish another internet-facing application, add a forwarding rule to the external load balancer and a NAT rule on the active firewall. The firewalls do not need to be redeployed.

In this section, you deploy a web application on a new VM (app-vm) in the trust subnet and publish it on a new public address.

  1. In Cloud Shell, save the deployment's zone, region, trust subnet, and external load balancer to environment variables.

    read ZONE SUBNET <<< "$(gcloud compute instances list \
        --filter='tags.items=(panw-tutorial) AND name~vmseries01' \
        --format='value(zone.basename(), networkInterfaces[2].subnetwork.basename())')"
    
    export REGION=${ZONE%-*}
    
    export EXTERNAL_LB=$(gcloud compute backend-services list \
        --filter="name~extlb" \
        --format="value(name)")
    
  2. Create app-vm in the trust subnet. Its startup script (scripts/app_startup.sh) installs a sample web application.

    gcloud compute instances create app-vm \
        --zone=$ZONE \
        --subnet=$SUBNET \
        --no-address \
        --machine-type=e2-small \
        --image-project=debian-cloud \
        --image-family=debian-13 \
        --metadata=startup-script-url=https://raw.githubusercontent.com/PaloAltoNetworks/google-cloud-vmseries-ha-tutorial/main/scripts/app_startup.sh
    
  3. Create a forwarding rule (fwd-rule-app-vm) on the external load balancer. This gives the application its own public address and sends its traffic through the firewalls' untrust interfaces.

    gcloud compute forwarding-rules create fwd-rule-app-vm \
        --region=$REGION \
        --load-balancing-scheme=EXTERNAL \
        --ip-protocol=L3_DEFAULT \
        --ports=ALL \
        --backend-service=$EXTERNAL_LB
    
  4. Save the two addresses for the NAT rule.

    export APP_PUBLIC_IP=$(gcloud compute forwarding-rules describe fwd-rule-app-vm \
        --region=$REGION \
        --format='value(IPAddress)')
    
    export APP_PRIVATE_IP=$(gcloud compute instances describe app-vm \
        --zone=$ZONE \
        --format='value(networkInterfaces[0].networkIP)')
    
    echo "Destination Address (forwarding rule): $APP_PUBLIC_IP"
    echo "Translated Address (app-vm):           $APP_PRIVATE_IP"
    
  5. On the active firewall, go to Policies → NAT, click Add, and name the rule inbound-app2.

  6. In the Original Packet tab, set the following:

    Field Value
    Source Zone untrust
    Destination Zone untrust
    Service service-http
    Destination Address The Destination Address from step 4
  7. In the Translated Packet tab, set Destination Address Translation as follows:

    Field Value
    Translation Type Static IP
    Translated Address The Translated Address from step 4
    Translated Port 80
  8. Click OK, then Commit.

  9. Open the application in a web browser. If the page does not load, wait a minute for the app-vm startup script to finish.

    echo http://$APP_PUBLIC_IP
    
  10. On the active firewall, go to Monitor → Traffic to view the traffic to app-vm.

Clean up

To avoid charges to your Google Cloud account, delete the resources you created in this tutorial.

  1. If you completed the Onboard internet applications section, delete the forwarding rule and app-vm first. Terraform cannot delete the external load balancer while the forwarding rule uses it, or the trust subnet while app-vm is in it.

    gcloud compute forwarding-rules delete --quiet \
        $(gcloud compute forwarding-rules list --filter="name=fwd-rule-app-vm" --uri)
    
    gcloud compute instances delete --quiet \
        $(gcloud compute instances list --filter="name=app-vm" --uri)
    
  2. From the repository directory, delete the remaining resources. Enter yes when prompted.

    terraform destroy
    

    When the deletion completes, Terraform displays Destroy complete!.

Additional information

About

Terraform tutorial detailing how to deploy Active/Passive VM-Series with session sync in Google Cloud.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

7 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages