Route Internet from eth0 to openvpn to eth1
I need to route all traffic coming and going from/to eth0 through openVPN before I send/receive it to/from eth1, this is a virtual machine Debian, you can call it a virtual router.
The idea is to put a dhcp on eth1, clients will connect to eth1. I want all clients to automatically be connected to the VPN.
Currently, I can route eth0 to eth1 with a DHCP in between, so clients will get their IP address and are able to browse, but as soon as I turn on openVPN, the clients can't access internet anymore.
To illustrate what I want, this might help:
How to achieve this?
Solution 1:
I presume you are NATting your system via iptables, with something like:
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
This is nearly right, all you have to do is to change the first one to:
iptables --table nat --append POSTROUTING --out-interface tun3 -j MASQUERADE
and now all of your traffic will go through the OpenVPN.