Linux – Why i can’t access computers in LAN behind OpenVPN server

linuxnetworkingopenvpnroutevpn

On ESXI server i have several VMs: one with external ip address (and internet access), that is configured as NAT (and plays OpenVPN server role) and several VMs in VLAN (using 192.168.182.*/28 ip addresses).

I have set up OpenVPN server & client as described in debian docs to access those VLAN virtual machines.

Currently i have running (tun) OpenVPN server & client, i can ping each other via tun0 interface.

The problem is that i can't ping from OpenVPN client machines that are in ESXI VLAN. Could you please advise a way to fix that?

OpenVPN client routing table:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         88.198.179.46   0.0.0.0         UG    0      0        0 eth0
10.9.8.1        0.0.0.0         255.255.255.255 UH    0      0        0 tun0
88.198.179.40   0.0.0.0         255.255.255.248 U     0      0        0 eth0

OpenVPN server routing table:

default         static.193.120. 0.0.0.0         UG    0      0        0 eth0
10.9.8.2        *               255.255.255.255 UH    0      0        0 tun0
46.4.120.192    *               255.255.255.224 U     0      0        0 eth0
192.168.182.16  *               255.255.255.240 U     0      0        0 eth1

As i understand, i have to route packets on OpenVPN server to 192.168.182.*/28 VLAN.

I have enabled ipv4 forwarding using following command:
echo "1" > /proc/sys/net/ipv4/ip_forward

I have added following rules to iptables (88.198.179.41/29 is client ip/subnet), but this did not help:

*nat
-A POSTROUTING -s 192.168.0.0/16 -o eth0 -j SNAT --to-source 46.4.120.218
COMMIT

*filter
-A FORWARD -s 192.168.182.0/24 -d 88.198.179.41/29 -j ACCEPT
-A FORWARD -d 192.168.182.0/24 -s 88.198.179.41/29 -j ACCEPT
COMMIT

Perhaps i have to define some route on VPNClient?

Best Answer

You didn't post your openvpn config, but I'm guessing you're missing the route to the rest of the LAN:

push "route 192.168.182.0 255.255.255.240"

This will add the necessary route on the client when they connect. Also, make sure that the other clients on your LAN know to use the OpenVPN server as their gateway for the OpenVPN network.