Openvpn – How to set up OpenVPN to let the VPN clients to access all the servers inside the server LAN

openvpnvpn

My server LAN IP is 192.168.1.1 and there is an intranet web server on 192.168.1.2
The OpenVPN daemon is configured to give clients 192.168.2.* addresses.

There is push "route 192.168.1.0 255.255.255.0" line in the config which I expect to enable the VPN clients to access the entire 192.168.1.0 net, but they can only access 192.168.1.1 – the VPN server itself.

I've tried enabling net.ipv4.ip_forward = 1 in /etc/sysctl.conf but this doesn't help.

Any ideas?

PS: The server runs Ubuntu 12.04.
PPS: OpenVPN runs in tun mode over UDP.

Best Answer

Make sure that the ip forwarding is acutally enabled

echo 1 > /proc/sys/net/ipv4/ip_forward

Also, in order for route push to work, the servers on the inside also needs to know the route to your OpenVPN client IP address. So they will need to know the route to 192.168.2.0/24

You can most likely make iptables do the routing via masquerade using

/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -i eth0 -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT