0

I have two internet connections. Default eth0 and a vpn tunnel on tun0.

my ip show route shows:

default via 149.202.xxx.xxx dev eth0
10.8.8.0/24 dev tun0  proto kernel  scope link  src 10.8.8.234
149.202.xxx.0/24 dev eth0  proto kernel  scope link  src 149.202.xxx.yy

Gateway for tun0 is 10.8.8.1 although I dont want to set it up as default. What I would like to do is for example use ping -I tun0 8.8.8.8, or curl --interface tun0 http://somewebsite.com and in this particular situation I would like to use tun0 as my outgoing connection.

Is it possible?

0

This is what worked for me:

echo "10 vpn" >> /etc/iproute2/rt_tables
ip route add default via 10.8.8.1 dev tun0 table vpn
ip rule add from 10.8.8.234/32 table vpn
ip rule add to 10.8.8.1/32 table vpn
ip route flush cache

And proof:

$ curl ifconfig.co
149.202.xxx.xxx

$ curl --interface tun0 ifconfig.co
178.250.xxx.xxx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.