I would like to achieve to use my openvpn-connection as default gateway for another host in the same subnet. I have 2 Hosts in the same subnet, both of them with Ubuntu Server 14.04.
Host A runs OpenVPN in order to establish a connection to my openvpn-exit-node. This host has been modified in order to allow ip-forwarding.
Host B is a client-app-server and should use the internet-connection through the shared openvn-connection from Host A. As I've setup the gateway-ip of Host B to the IP of Host A, the traffic from Host B now is routed through the openvpn-connection of Host A.
The problem appears as the openvpn-connection on Host A drops (at least every 24hours here in Germany) and reconnects; afterwards Host B uses the default gw from Host A and bypass the openvpn-connection (sometimes until the tunnel is up again and everytime Host B reboots).
The achievement should be, to ensure that Host B gets internet only through the openvpn-connection. Is there any possibility to ensure, that Host B only has access to the internet as long as it uses the openvn-tunnel?
Host A (eth0 ip:10.11.12.6/gw:10.11.12.1) (tun0 ip:10.8.0.146/gw:10.8.0.145):
- Installed OpenVPN and configured the client-connection to my openvn-exit-node: works
- Configured Host A in order to allow ip-forwarding and configured IP Masquerading: works
Host B (eth0 ip:10.11.12.9/gw:10.11.12.6): - Changed the default gateway to the ip-address of Host A: works - All traffic uses the openvpn-tunnel on Host A
Problem: Everytime the openvpn-connection drops and/or openvpn reconnects, Host B seems to switch back using the default gateway of Host A. Host B in such a moment should remain without internet-access but instead its using the connection Host A uses to connect to the openvpn-gateway.
Kind regards, D0C