Overcome transitive VPC limitations in Google Cloud.
Network and Automation Architect
Google Cloud Platform (GCP) offers robust networking features, including Virtual Private Clouds (VPCs) and VPC peering, to facilitate secure communication within and between networks. However, a persistent challenge arises in scenarios where VPCs cannot directly exchange prefixes due to the transitive VPC issue. In this article, we delve into a comprehensive solution involving the deployment of a Phantom VM within an intermediate VPC, enabling seamless communication between distinct VPCs with distinct subnets.
Consider a scenario with three VPCs: VPC1 (172.16.1.0/24
), VPC2 (172.16.2.0/24
), and an intermediate VPC3 (172.16.100.0/24
). Due to the transitive VPC issue, VPC1 and VPC2 cannot establish direct peering, hindering the flow of traffic between their subnets.
To address this challenge, we implement a Phantom VM within VPC3, acting as an intermediary for traffic between VPC1 and VPC2. The following detailed steps outline the implementation:
Creation of Phantom VM:
Subnet Configuration:
Routing Configuration on Phantom VM:
172.16.0.0/16
), with the next hop pointing to the Phantom VM itself.Advertisement to VPCs:
172.16.0.0/16
) from the Phantom VM to both VPC1 and VPC2 using Cloud Router configurations.IP Forwarding Enablement and Static Route Addition on Phantom VM:
# Enable IP forwarding temporarily (valid until the next reboot)
sudo sysctl -w net.ipv4.ip_forward=1
# Enable IP forwarding persistently (across reboots)
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
# Add a static route for the combined address space (172.16.0.0/16)
sudo ip route add 172.16.0.0/16 via 172.16.100.1
VPC1 to VPC3:
172.16.0.0/16
received through VPC3, forwards the traffic to VPC3.Processing at Phantom VM:
VPC3 to VPC2:
172.16.0.0/16
, directs the traffic towards VPC2.Arrival at VPC2:
Deploying a Phantom VM within an intermediate VPC emerges as a powerful solution to overcome the transitive VPC issue in GCP. This meticulous approach ensures a detailed configuration of routes, IP forwarding, and routing on the Phantom VM, facilitating efficient and secure communication between VPCs with distinct subnets.