0

I'm using a debian based desktop distro, but I imagine that is probably irrelevant. I have a very simple query that I can seem to find the answer to anywhere, probably because no one does this. I have connected to two vpn services at the same time (so tun0 and tun1 in this istance). What I want to know is how I can choose to route all internet traffic to Tun1 or vice versa. I found this post and it provides a little insight, but its more granular than what I require.

Split tunneling through two VPNs simeltaneously

I'm certain there is a config somewhere that I can point http, https to go through tun1 instead of tun0 and vice versa?

thanks in advance t.

Turducken
  • 1
  • 1

1 Answers1

1

To route all internet traffic to one interface, just set the default route to point to that interface.

ip route del default
ip route add default via tun0

or

ip route replace default via tun0

Edit

If you want different routes based on properties besides the destination, you an use policy based routing, see man ip-rule.

First you need a rule to match your criteria. If you want to capture the default http and https ports, these are the ports 80 and 443. The table number 200 is arbitrary, just don't use a number already in use an use the same number later.

ip rule add dport 80 table 200
ip rule add dport 443 table 200

Now you need some rules for table 200.

ip route add default table 200 dev tun0

While other traffic uses the default table

ip route add default dev tun1
RalfFriedl
  • 3,108
  • 4
  • 13
  • 17