cyberhippo
cyberhippo

Reputation: 61

GCP VPC Peering (auto-mode)

I have two GCP projects which have their own VPC (created in auto-mode) and I would like to create a VPC peering connection between them in order for the compute instances in both VPCs to communicate with each other.

But since the VPCs were created in auto-mode, the subnets of both networks are using the same predefined range of IP addresses meaning that I cannot connect the VPCs together because the IP ranges are overlapping.

In the two VPCs, my compute instances are in the "same" subnet and converting the subnet mode (from auto to custom) could allow me to change the IP range of those subnets. But the new IP CIDR range needs to be a superset of the current IP CIDR range and the IP ranges will still be overlapping.

What could be a solution here ?

Note that I do not need to have a subnet created in each region since I am only using 1 or 2 subnets as of now.

Upvotes: 1

Views: 1449

Answers (1)

Wojtek_B
Wojtek_B

Reputation: 4443

You can't connect (using VPC peering) networks with overlapping IP ranges. Routing wouldn't work.

But - there are several solutions to this issue.

  1. Migrate VM's. Depending on number of VM's and your use case it's the most tedious way (you have to migrate every VM by hand and - it has to be stopped). So - it may or may not be possible for you. But - if you have a few VM's a can migrate them then that might be good idea. You can alway expand VPC IP range if it will get too small at some point in time.

  2. Have both subnets converted to custom mode and make them smaller (such as 192.168.0.0/25 and 192.168.0.128/25. Combining the two you will get 192.168.0.0/24 address range. But if this is a viable solution for you depends if you have desired IP range available or can move the addresses without too much hassle.

  3. You can set up third "intermediate" network and set up two NAT's between:

net1 > NAT > intermediate_net NAT > net2

But this solution seems like an overkiil for what you're trying to do.

You can have a look at one of my answers - it's about connecting networks with VPN but it's a very similar concept.

Upvotes: 3

Related Questions