This tutorial describes how to configure a global network firewall policy to allow internal traffic between VM subnets in a custom VPC network.
Objectives
This tutorial shows you how to complete the following tasks:- Create a custom VPC network with two subnets.
- Create two Linux VM instances (a client VM and a server VM) without external IP addresses in separate subnets of the VPC network.
- Create a Cloud Router and a Cloud NAT gateway as a best practice to download software packages.
- Install the Apache server on the server VM.
- Create a global network firewall policy with the following rules:
- Allow egress traffic to any destination.
- Enable firewall logging.
- Use Identity-Aware Proxy (IAP) to allow SSH connectivity to the VMs.
- Allow the client VM to connect to the server VM running the Apache server.
- Test the connection.
The following diagram shows the flow of the traffic between subnets of a custom VPC network after a global network firewall policy allows internal ingress traffic.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
- Enable the Compute Engine API for your project.
- Make sure that you have the Compute Network Admin (
roles/compute.networkAdmin) Identity and Access Management (IAM) role. - If you prefer to work from the command line, install the Google Cloud CLI. For the conceptual and installation information about the tool,
see gcloud CLI overview.
Note: If you haven't run the Google Cloud CLI previously, first run
gcloud initto initialize your gcloud CLI directory.