Skip to content
Visual explainer 3h to learn 5 steps

Shared VPC, Private Service Connect and hybrid links

Compare Shared VPC, peering, Private Service Connect, Cloud VPN and Interconnect and fix a common DNS or permission problem.

By Invicly Tech, , in Google Cloud Engineering and Services. About 9 minutes to read.

Topic 9 of 32

In short

Real companies have many projects and often an office or data centre. Shared VPC lets many projects use one central network. Peering, Private Service Connect, Cloud VPN and Interconnect connect networks together in different ways.

Think of it like this: Shared VPC is one office building rented by several teams. Peering is a private door between two buildings. VPN is a secure tunnel; Interconnect is your own cable.

Explained simply

A small team can keep everything in one project. A bigger company usually has many projects, one for each team or app. If each project had its own network, the networks would need to be joined, and rules would be scattered.

Shared VPC fixes this. One host project owns the network. Other projects, called service projects, run their machines in the shared subnets. The network team controls addresses and firewalls. App teams control their own workloads.

Sometimes you need to link separate networks. VPC peering joins two networks so they can see each other. Private Service Connect is narrower: it gives you a private address that leads to one service, in your own or someone else's network.

To link to an office or data centre, you have two main choices. Cloud VPN is an encrypted tunnel over the internet and is quick to set up. Cloud Interconnect is a private physical connection, better for large or steady traffic but slower to order.

Press Play on a diagram to walk through it one step at a time.

MapShared VPC layout
Organization
  • Host project
    • Owns the VPC and subnets
    • Owns firewall rules
    • Network team works here
  • Service project A
    • VMs use a host subnet
    • Needs networkUser on the subnet
  • Service project B
    • Cloud Run or GKE can use it too
    • Own billing and IAM
CompareWhich connection to pick
Peering
  • Joins two VPCs
  • Ranges must not overlap
  • Not transitive
  • Good for network-to-network
Private Service Connect
  • Exposes one service, not a network
  • Ranges may overlap
  • Consumer gets a private IP endpoint
  • Good for one producer, many consumers
Cloud VPN or Interconnect
  • Link to on-premises or other clouds
  • VPN runs over the internet, encrypted
  • Interconnect is a private physical link
  • HA VPN is the usual VPN
FlowDecision path for connecting networks
  1. 1
    Need one service only?

    Yes: Private Service Connect

  2. 2
    Two VPCs, no overlap?

    Yes: VPC peering

  3. 3
    Many projects, one team?

    Yes: Shared VPC

  4. 4
    Link to on-premises?

    Start with HA VPN

  5. 5
    Need big, steady links?

    Add Interconnect

In depth

Shared VPC roles and setup

A Shared VPC Admin enables a host project at the organization or folder level, then attaches service projects. Then you decide who may use which subnet. A principal needs the Compute Network User role (roles/compute.networkUser) on the subnet, or on the host project for all subnets. Service accounts used by services such as GKE or Cloud Run need the same. If a team sees an error that the subnet is not found or permission is denied when creating a VM in a shared subnet, this role is almost always the missing piece.

  • Grant networkUser on single subnets when you can.
  • Firewall rules live in the host project.
  • A project can be a host or a service project, not both.

Peering versus Private Service Connect

VPC Network Peering exchanges subnet routes between two networks. It needs non-overlapping ranges and is not transitive: if A peers with B and B peers with C, A cannot reach C through B. Private Service Connect creates an endpoint with an internal IP in the consumer network that forwards to a published service or a Google API bundle. Ranges can overlap because only that one address is exposed. Use peering for wide network-to-network access. Use Private Service Connect when a team or vendor wants to offer one service to many consumers safely.

SequenceReaching a service through Private Service Connect
Consumer VM
PSC endpoint (10.1.0.5)
Producer service
  1. 1Connect to 10.1.0.5:443
    Consumer VM to PSC endpoint (10.1.0.5): Connect to 10.1.0.5:443
  2. 2Forward over Google's network
    PSC endpoint (10.1.0.5) to Producer service: Forward over Google's network
  3. 3Service reply
    Producer service to PSC endpoint (10.1.0.5): Service reply
  4. 4Reply to the VM
    PSC endpoint (10.1.0.5) to Consumer VM: Reply to the VM

Cloud VPN or Interconnect

HA VPN has two interfaces and, when configured with the right tunnels, carries Google's 99.99 percent availability SLA. It uses IPsec over the public internet and Cloud Router with BGP to exchange routes. Interconnect avoids the public internet. Dedicated Interconnect connects your equipment to Google at a colocation facility. Partner Interconnect uses a service provider and can start at smaller speeds. Choose VPN to start fast or for modest traffic. Choose Interconnect for high bandwidth, steady performance or compliance. Many teams start with VPN and add Interconnect later. Interconnect has setup lead time and costs, so check current pricing.

Fixing private DNS

Cloud DNS private zones answer only for networks you attach. If a VM in one VPC cannot resolve a name from another, check which networks the zone is visible to. DNS peering zones let one VPC use the zones of another. Forwarding zones send queries for a domain to on-premises resolvers; the reverse needs an inbound server policy so on-premises machines can query Cloud DNS. Firewalls on the hybrid link must allow UDP and TCP port 53. Always test with dig from a VM in the failing network.

  • Private zone: attach to the right networks.
  • Forwarding zone: cloud to on-premises names.
  • Inbound policy: on-premises to cloud names.

Learn it in 5 short steps

About 35m each. Track them with a timer in your plan.

  1. 1
    Use Shared VPC host and service projects~35m
  2. 2
    Compare peering and Private Service Connect~35m
  3. 3
    Choose Cloud VPN or Interconnect~35m
  4. 4
    Fix private DNS resolution~35m
  5. 5
    Grant network user permissions~35m

Key points

  • Shared VPC separates duties: a host project owns the network, service projects own workloads.
  • Peering joins whole networks and is not transitive; Private Service Connect exposes a single service.
  • Start with HA VPN for hybrid links. Choose Interconnect when you need steady bandwidth or lower latency.
  • Private DNS problems are the most common hybrid fault. Check zones, forwarding and peering for DNS.
  • To use a shared subnet, a principal needs the Compute Network User role on that subnet or host project.

Key terms

Tap a card to flip it. 0/5 known

Examples

bash
gcloud compute shared-vpc enable HOST_PROJECT_ID
gcloud compute shared-vpc associated-projects add SERVICE_PROJECT_ID \
  --host-project=HOST_PROJECT_ID
gcloud compute networks subnets add-iam-policy-binding shared-subnet \
  --project=HOST_PROJECT_ID --region=us-central1 \
  --member="user:dev@example.com" --role="roles/compute.networkUser"

Enable Shared VPC and attach a service project. IDs are placeholders.

Attach a service project and grant access

You are the network admin. Enable the host project, attach one service project, and let one developer use a single subnet. Shared VPC needs an organization, so a personal project without one cannot practise this; use a free design-only exercise on paper instead. Rollback: remove the association and disable the host.

bash
gcloud compute shared-vpc enable HOST_PROJECT_ID
gcloud compute shared-vpc associated-projects add SERVICE_PROJECT_ID \
  --host-project=HOST_PROJECT_ID
gcloud compute networks subnets add-iam-policy-binding app-subnet \
  --project=HOST_PROJECT_ID --region=us-central1 \
  --member="user:dev@example.com" --role="roles/compute.networkUser"

Fix a private name that does not resolve

A VM in the app VPC cannot resolve db.internal.example.com, which lives in a private zone attached only to the hub VPC. Add the app VPC to the zone or create a peering zone. Verify with dig. This is a good exercise with example.com names and no cost beyond DNS queries.

bash
dig db.internal.example.com
gcloud dns managed-zones update internal-zone \
  --networks=hub-vpc,app-vpc
dig db.internal.example.com

Quick reference

  • Shared VPC: host project owns the network, service projects use shared subnets.
  • Needed role on a shared subnet: roles/compute.networkUser.
  • Peering: no overlapping ranges, not transitive.
  • Private Service Connect: one service through an internal IP; ranges may overlap.
  • HA VPN: IPsec over the internet with Cloud Router and BGP.
  • Interconnect: private link, Dedicated or Partner.
  • Private DNS zones answer only for networks attached to them.

Common mistakes

  • Peering two VPCs with overlapping ranges. The peering will not work.
  • Expecting peering to pass traffic through a third network. It does not.
  • Granting network access at project level when one subnet would do.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Which role lets a user create a VM in a shared subnet?

Question 2

2Network A peers with B, and B peers with C. Can A reach C through B?

Question 3

3Two networks use the same 10.0.0.0/16 range. You only need one API from one. Best option?

Question 4

4You need an encrypted link to the office by next week. Which is the usual start?

Question 5

5A forwarding zone in Cloud DNS is used to:

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Say which project owns firewall rules in Shared VPC and which project owns the VMs.

  2. Exercise 2medium

    Pick peering or Private Service Connect for a vendor that offers one API to 50 customers with unknown ranges. Explain.

  3. Exercise 3hard

    Design a hybrid link for an office with a 200 Mbps need and a 4-hour outage limit per year. State what you choose and what you would measure.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Do I need an organization for Shared VPC?
Yes. Shared VPC works within a Google Cloud organization.
Is VPN traffic encrypted?
Yes, Cloud VPN uses IPsec. Interconnect is private but not encrypted by default, so add encryption if your rules require it.
Why can I not peer two of my networks?
The most common cause is overlapping IP ranges. Check the subnet ranges in both networks.

Go deeper

ShareXLinkedInWhatsApp