I have Ubuntu Server, and I would like to filter traffic and have only a specific users or groups traffic be sent through the VPN, and the rest of the traffic sent through the standard internet connection. I would think this would be rather easy to do, but I'm having a lot of trouble getting it set up.
I have been able to successfully set up a VPN connection using:
openvpn --config '/etc/openvpn/Sweden.ovpn' --auth-user-pass '/etc/openvpn/pia.txt' --persist-key --persist-tun --tls-client --remote-cert-tls server --user vpn &
The configuration file for OpenVPN contains the following:
client dev tun proto udp remote sweden.privateinternetaccess.com 1194 resolv-retry infinite nobind persist-key persist-tun ca ca.crt tls-client remote-cert-tls server auth-user-pass comp-lzo verb 1 reneg-sec 0
Which creates a new interface named "tun0". Using that interface works perfectly fine:
curl -v --interface tun0 icanhazip.com
However, when I attempt to use the eth0 interface, the connection will timeout:
curl -v --interface eth0 icanhazip.com
If I disable the OpenVPN connection, then my curl call through eth0 will work correctly.
Once I am able to get both eth0 and tun0 working, I had planned on using something similar to this command to route a specific group through the OpenVPN tunnel:
iptables -A OUTPUT -m owner --gid-owner vpn \! -o tun0 -j REJECT
Does anyone know of a way that I could get both eth0 and tun0 to work at the same time, so that I may route the traffic of a specific user/group through it and leave all other traffic alone?
Similar posts: How to route specific traffic through OpenVPN? - I only have one network card in my solver, this solution appears to use two network cards.