Page 1 of 1

Bind interface to VPN connection

Posted: Thu Oct 05, 2017 11:50 am
by tandr
Hi,

i have following szenario:

A pc with the following interfaces with openvpn client installed.

Interface wwan0 connects to the internet. It is configured via DHCP.
The wwan0 interface shall also be used for the openvpn connection.

wlan0 interface to connect to a wifi. Also configured via DHCP. The wifi may also provide an internet connection.

In general the openvpn connection does work. But if i have both connections established (wlan0 and wwan0 are connected)
the openvpn client does always use the wlan0 interface.

How can i prevent this - i assume the problem is related to the default gateway setting of my setup. Is that correct?

Thanks in advance

Re: Bind interface to VPN connection

Posted: Thu Oct 05, 2017 12:55 pm
by tandr
I forgot to mention that i am running linux on the client pc.

Re: Bind interface to VPN connection

Posted: Fri Apr 26, 2019 6:56 pm
by homedev
there is no mention of OS. You mentioned default gateway, ubuntu? if on linux, edit /etc/network/interfaces to include "gateway x.x.x.x" to route traffic through the desired interface, there is also the ip tables,
sudo iptables -A FORWARD -o tun0 -i eth0 -s 192.168.1.0/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE


UGH BORING.

or on any operating system, just disable the interface you dont want traffic to flow through.

Re: Bind interface to VPN connection

Posted: Mon Aug 09, 2021 9:49 pm
by jmorris644
@tandr, Did this provide the answer you are looking for? I am trying to do the same thing. I want to force the VPN to get established using a specific network interface.