I have two Linux machine in GCP(one is client is in vpc1-network eth1 IP 10.20.3.2/24 and other is server which is in vpc2-network eth1 ip 10.20.4.2/24) The third Linux machine in GCP is IP forwarder machine having two interface eth1 IP 10.20.3.3/24 and eth2 10.20.4.3/24. I configured linux IP forwarder machine using net.ipv4.ip_forward=1 to forward traffic from 10.20.3.3 and 10.20.4.3. Is it possible to ping server(10.20.4.2) from client(10.20.3.2) using this setup? What routing table in GCP I setup so that i don't need to configure anything specifically routing in client and server Linux machine. Is it possible?
Hi @saurin ,
@saurin wrote:
Is it possible to ping server(10.20.4.2) from client(10.20.3.2) using this setup?
Yes, based on your setup description, you should be able to ping the server (10.20.4.2) from the client (10.20.3.2) through the IP forwarder machine.
Since the client and the IP forwarder are in the same VPC1 network, the client will send the packet to the IP forwarder using its internal IP (10.20.3.3). The IP forwarder receives the packet on its eth1 interface (10.20.3.3). Then, packet is sent out from the eth2 interface (10.20.4.3) towards the server.
On the server side, it receives the packet on its eth1 interface with IP 10.20.4.2. The server then processes the ping request and sends back the response, back through the IP forwarder, which forwards it from eth2 to eth1.
@saurin wrote:
What routing table in GCP I setup so that i don't need to configure anything specifically routing in client and server Linux machine. Is it possible?
You can start by creating custom routes to define the paths for traffic between your VPC networks. Based on your setup:
For VPC1:
Destination IP Range: 10.20.4.0/24 (CIDR block of VPC2)
Next Hop: Internal IP of the IP forwarder in VPC1 (e.g., 10.20.3.3)
For VPC2:
Destination IP Range: 10.20.3.0/24 (CIDR block of VPC1)
Next Hop: Internal IP of the IP forwarder in VPC2 (e.g., 10.20.4.3)
On the IP forwarder machine, make sure IP forwarding is enabled. Make sure you do this with net.ipv4.ip_forward=1
.
Last important note, make sure the client and server Linux machines use the default routes provided by DHCP.