Google Cloud Network PeeringNetwork

Google Cloud Network Peering allows you to establish private, high-bandwidth connections between virtual networks in the same or different Google Cloud projects. This enables communication between resources in different networks as if they were part of the same network, without using external IP addresses.

Features

  1. Private Connectivity:

    • Network Peering provides private connectivity between virtual networks, allowing resources to communicate securely without going through the public internet.
  2. Transitive Routing:
    • Network Peering supports transitive routing, meaning that if Network A is peered with Network B and Network B is peered with Network C, then resources in Network A can communicate with resources in Network C.
  3. Shared VPC:
    • Network Peering is commonly used in Shared VPC configurations, allowing resources in different projects to communicate within a common VPC.
  4. Granular Control:
    • You can control which subnets are shared and limit the scope of the peering to specific subnets within the networks.
  5. Dynamic Routing:
    • Cloud Router can be used to dynamically exchange routes between the peered networks, ensuring efficient and automatic routing.

Configuration Example

Here's a basic example of setting up Network Peering between two Google Cloud projects:

  1. Enable API and Set Up Projects:

    • In the Google Cloud Console, enable the Compute Engine API and create two projects, representing the networks you want to peer.
  2. Create VPC Networks:
    • In each project, create the VPC networks that you want to peer.
    bash
    gcloud compute networks create network-a --project=project-a  gcloud compute networks create network-b --project=project-b
    
    
  3. Create Subnets:
    • Create subnets in each network.
    bash
    gcloud compute networks subnets create subnet-a --network=network-a --project=project-a --region=us-central1 --range=10.1.0.0/24  gcloud compute networks subnets create subnet-b --network=network-b --project=project-b --region=us-central1 --range=10.2.0.0/24
    
    
  4. Enable API and Create Peering:
    • In each project, enable the Compute Engine API and create a network peering.
    bash
    gcloud compute networks peerings create peering-a-to-b --project=project-a --network=network-a --peer-project=project-b --peer-network=network-b --auto-create-routes  gcloud compute networks peerings create peering-b-to-a --project=project-b --network=network-b --peer-project=project-a --peer-network=network-a --auto-create-routes
    
    
  5. Configure Firewall Rules:
    • Ensure that firewall rules are configured to allow the necessary traffic between the peered networks.
    bash
    gcloud compute firewall-rules create allow-internal-a-to-b --project=project-a --network=network-a --allow=INTERNAL --source-ranges=10.2.0.0/24  gcloud compute firewall-rules create allow-internal-b-to-a --project=project-b --network=network-b --allow=INTERNAL --source-ranges=10.1.0.0/24
    
    
  6. Verify Connectivity:
    • Deploy resources in each network and verify that they can communicate with each other using internal IP addresses.

Always refer to the official documentation for the most up-to-date and detailed information on configuring Google Cloud Network Peering. Adjust the commands based on your specific requirements, such as region, IP ranges, and firewall rules.