Peer two VPC networks
In this quickstart, learn how to peer two Virtual Private Cloud (VPC) networksby using the Google Cloud console.
Consider an organizationorganization-a that needs VPC Network Peeringto be established betweennetwork-a inproject-a andnetwork-b inproject-b. In order for VPC Network Peering to be establishedsuccessfully, administrators ofnetwork-a andnetwork-b must separatelyconfigure the peering association.
By completing the steps on this page, you create the following configuration:
The peering connection is inindependent mode(default).
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.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the 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.
If you're using an existing project for this guide,verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
Verify that billing is enabled for your Google Cloud project.
Enable the Compute Engine API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission.Learn how to grant roles.In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the 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.
If you're using an existing project for this guide,verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
Verify that billing is enabled for your Google Cloud project.
Enable the Compute Engine API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission.Learn how to grant roles.- Repeat these steps for a second project. This quickstart describes how to peer VPC networks that are in separate projects.
Required roles
To get the permissions that you need to peer two VPC networks, ask your administrator to grant you the following IAM roles on the project:
- Compute Network Admin (
roles/compute.networkAdmin) - Compute Security Admin (
roles/compute.securityAdmin)
For more information about granting roles, seeManage access to projects, folders, and organizations.
You might also be able to get the required permissions throughcustom roles or otherpredefined roles.
Create two VPC networks
In this section, you create two VPC networks, each in differentprojects.
Createnetwork-a andsubnet-a in your first project
Console
In the Google Cloud console, go to theVPC networks page.
ClickCreate VPC network.
In theName field, enter
network-a.In theNew subnet section, specify the following:
- In theName field, enter
subnet-a. - Select anyRegion.
- In theIPv4 range field, enter
10.0.1.0/24. - ClickDone.
- In theName field, enter
In theIPv4 firewall rules tab, on theright side of the row that contains the predefined ingressfirewall rule named
NETWORK-allow-custom, clickEdit.- DeselectUse subnets' IPv4 ranges.
- InOther IPv4 ranges, enter
10.0.0.0/20. Entering this rangeensures that the resources in your peered networks cancommunicate with each other and lets you add more subnets in thefuture without having to update firewall rules. - ClickConfirm.
ClickCreate.
Createnetwork-b andsubnet-b in your second project
Console
In the Google Cloud console, go to theVPC networks page.
ClickCreate VPC network.
In theName field, enter
network-b.In theNew subnet section, specify the following:
- In theName field, enter
subnet-b. - Select anyRegion.
- In theIPv4 range field, enter
10.0.8.0/24. - ClickDone.
- In theName field, enter
In theIPv4 firewall rules tab, on theright side of the row that contains the predefined ingressfirewall rule named
NETWORK-allow-custom, clickEdit.- DeselectUse subnets' IPv4 ranges.
- InOther IPv4 ranges, enter
10.0.0.0/20. Entering this rangeensures that the resources in your peered networks cancommunicate with each other and lets you add more subnets in thefuture without having to update firewall rules. - ClickConfirm.
ClickCreate.
Peernetwork-a withnetwork-b
In this section, you configurenetwork-a to peer withnetwork-b.
Console
In the Google Cloud console, go to theVPC Network Peering page.
ClickCreate connection.
ClickContinue.
Enter aName of
peer-abfor this side of the connection.UnderYour VPC network, select
network-a.Set thePeering VPC network radio buttons to
In another project.Specify theProject ID of the other project.
Specify theVPC network name of the other network,
network-b.SelectImport custom routes andExport custom routes.
ClickCreate.
At this point, the peering state remainsINACTIVE because of the absence of a matchingconfiguration innetwork-b inproject-b.
When the peering state becomesACTIVE, VPC Network Peering automaticallyexchanges subnet routes. Google Cloud also exchanges custom routes (staticroutes and dynamic routes) by importing or exporting them over the peeringconnection. Both networks must be configured to exchange custom routes beforethey are shared. For more information, seeImporting and exporting customroutes.
To see the current peering state, view the peering connection:
Console
In the Google Cloud console, go to theVPC Network Peering page.
Select
peer-ab. On thePeering connection details page, thestatus saysInactive. Waiting for the connection to be created by network-b.
Peernetwork-b withnetwork-a
In this section, you create a matching peering configuration fromnetwork-b tonetwork-a so that the peering becomesACTIVE on both ends.
Console
In the Google Cloud console, go to theVPC Network Peering page.
ClickCreate connection.
ClickContinue.
Enter aName of
peer-bafor this side of the connection.UnderYour VPC network, select the
network-b.Set thePeering VPC network radio buttons to
In another project.Specify theProject ID of the other project.
Specify theVPC network name of the other network,
network-b.SelectImport custom routes andExport custom routes.
ClickCreate.
VPC Network Peering becomesACTIVE
As soon as the peering moves to anACTIVE state, subnet routes and customroutes are exchanged, which allows traffic to flow between resources in thenetworks.
Console
In the Google Cloud console, go to theVPC Network Peering page.
On the VPC Network Peering page, the status for the connection thatyou created says
ACTIVE.Go to the VPC Network Peering page in the other project to seethat it also says
ACTIVE.
The routes to peered network CIDR prefixes are now visible across theVPC network peers. These routes are implicit routes that aregenerated for active peering connections. They don't have corresponding routeresources. The following procedure shows routes for all VPCnetworks forproject-a.
Console
In the Google Cloud console, go to theRoutes page.
ForNetwork andRegion, select
network-aand the region inwhich you createdsubnet-a, then clickView.In the list of routes, there is a
Peering subnetroute forsubnet-b.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
Delete the projects
To delete the projects that you created:
Delete individual resources
If you don't want to delete the entire project, delete the VPC Network Peeringconnections and the VPC networks that you created.
Before you can delete a network, you must delete its VPC Network Peeringconnection.
Delete VPC Network Peering connections
To delete a VPC Network Peering connection:
Console
In the Google Cloud console, go to theVPC Network Peering page.
Select the checkbox next to the peering you want to remove.
ClickDelete.
Delete VPC networks
To delete a VPC network:
Console
In the Google Cloud console, go to theVPC networks page.
Click the name of a VPC network to show itsVPC networkdetails page.
ClickDelete VPC network.
In the message that appears, clickDelete to confirm.
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.