I have a setup a server that uses an OpenVPN client, in order to connect it to my private network at home. Whenever I start the VPN client-connection on the server, I can only connect to it's public IP address (188.226.161.x), only if am on the same VPN network. If the server is not connected to the VPN, then I can connect to it even if I am, or am not, currently using the VPN.
Question
Is there a way to allow me to connect to the public IP address of the server, even if I am not connected to the same VPN?
Extra Info
- There are no firewall rules on the server.
- The server is a Digital Ocean instance running Ubuntu 14.04
Routing table on server before VPN connection
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 188.226.161.1 0.0.0.0 UG 0 0 0 eth0
10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 lxcbr0
188.226.161.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
Routing table on server after VPN connection
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
0.0.0.0 188.226.161.1 0.0.0.0 UG 0 0 0 eth0
10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 lxcbr0
10.8.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
128.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
178.62.56.51 188.226.161.1 255.255.255.255 UGH 0 0 0 eth0
188.226.161.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
I found the solution to the problem with an answer from superuser. The problem is that the server is defaulting to using the tun0 interface rather than eth0, when really we want it to only use tun0 for the private network on 10.8.0.0 to 10.8.0.255. Thus the solution is to configure the client connection to only use the tun0 interface when connecting to other VPN IPs, rather than for the entire internet.
For me, this was done by adding the following two lines to the end of the client.conf file and restarting my openvpn connection:
This means that if the server is trying to connect to 10.8.0.0-255, it will use the tun0 interface. Any destination other than that, it will use the eth0 interface instead.