Linux – How to create routes for an OpenVPN tunnel

google-cloud-platformlinuxopenvpnroutingwindows

I have three instances created in google cloud platform, one of them hosts a linux system and the other a windows 2012 r2 server, I have already created the vpn tunnel between my client and my linux instance, the question here is what is it I have to do to be able to connect via RDP to my windows servers, the ip addresses of the instances are as follows:

Instance with OpenVpn installed:

Internal network interface, eth0: 10.128.0.3
Openvpn interface, tun0 10.8.0.1
Ip publishes 104.154.145.xxx

Windows server instance:

Internal network interface, eth0: 10.128.0.2
Ip publishes 35.184.137.xxx

Windows server instance:

Internal network interface, eth0: 10.128.0.3
Ip publishes 35.184.137.xxx

When I connect as a client, the OpenVpn service gives me ip: 10.8.0.6.

I'd like to connect to the Windows servers by RDP.

I believe it is related to some routing issue but I'm not sure, can you please assist?

Best Answer

I read all communications with Itai. Along with configuring routing in OpenVPN configuration file and Windows machine, you should enable forwarding on your Linux machine, to enable it, just add net.ipv4.ip_forward=1 to /etc/sysctl.conf and execute sysctl -p. After this you should add iptables rule by command iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE. It should be enough.

Don't forget to save iptables configuration by command service iptables save.