Bind interface to VPN connection

Scripts with setup, destroy, and modify routing tables and firewall rulesets for client connections.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
tandr
OpenVpn Newbie
Posts: 2
Joined: Thu Oct 05, 2017 11:42 am

Bind interface to VPN connection

Post by tandr » Thu Oct 05, 2017 11:50 am

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

tandr
OpenVpn Newbie
Posts: 2
Joined: Thu Oct 05, 2017 11:42 am

Re: Bind interface to VPN connection

Post by tandr » Thu Oct 05, 2017 12:55 pm

I forgot to mention that i am running linux on the client pc.

homedev
OpenVpn Newbie
Posts: 2
Joined: Fri Apr 26, 2019 6:32 pm

Re: Bind interface to VPN connection

Post by homedev » Fri Apr 26, 2019 6:56 pm

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.

jmorris644
OpenVpn Newbie
Posts: 1
Joined: Mon Aug 09, 2021 9:43 pm

Re: Bind interface to VPN connection

Post by jmorris644 » Mon Aug 09, 2021 9:49 pm

@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.

Post Reply