Edit
I solved the problem through writing a script to generate routing tables and rules, after following @MariusMatutiae's link to an introduction to policy routing
.
I'm attempting to run two OpenVPN clients on my Raspberry Pi running Minibian, and bind a specific application (get_iplayer) to one of the VPNs using bind.so as explained here and here. I originally followed the guide here, installing iproute
and downloading and compiling bind.so
as instructed there.
The VPNs
I am using config files provided by Private Internet Access.
One VPN points to their Switzerland server, uses udp, and I have set the option dev tun0
, as I wish this to be the main tunnel through which all traffic goes through except that which I declare explicitly through the use of of bind.so
. This tunnel works fine, all traffic seems to go through it.
The second VPN points to the London, UK server, uses tcp and has the option dev tun1
set to act as the second tunnel. This tunnel appears work fine when ran by itself. I can run get_iplayer correctly.
The problem occurs when I run both instances at the same time. No traffic seems to go through the tun1
interface, even when I attempt to use bind.so and the LD_PRELOAD
approach as explained in the links above.
bind.so
As far as I'm aware I have compiled bind.so properly, copied it to /usr/lib
, etc. Frustratingly, I did get it work once but I have no idea how that occurred.
Commands
I have been using ip route
to find the gateway address; I'm confident I am using the correct ip address. e.g.:
$ ip route
0.0.0.0/1 via 10.30.1.17 dev tun1
0.0.0.0/1 via 10.198.1.5 dev tun0
default via 192.168.1.254 dev eth0
10.30.1.1 via 10.30.1.17 dev tun1
10.30.1.17 dev tun1 proto kernel scope link src 10.30.1.18
10.198.1.1 via 10.198.1.5 dev tun0
10.198.1.5 dev tun0 proto kernel scope link src 10.198.1.6
104.238.169.140 via 192.168.1.254 dev eth0
128.0.0.0/1 via 10.30.1.17 dev tun1
128.0.0.0/1 via 10.198.1.5 dev tun0
179.43.177.66 via 192.168.1.254 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.84
Then running:
BIND_ADDR="10.30.1.17" LD_PRELOAD=/usr/lib/bind.so get_iplayer --type=tv
results in no connection and nothing in the log for the UK VPN.
Stopping the Switzerland VPN and running the same get_iplayer command results in a connection and information being downloaded. ip route
gives the following:
$ ip route
0.0.0.0/1 via 10.30.1.17 dev tun1
default via 192.168.1.254 dev eth0
10.30.1.1 via 10.30.1.17 dev tun1
10.30.1.17 dev tun1 proto kernel scope link src 10.30.1.18
104.238.169.119 via 192.168.1.254 dev eth0
128.0.0.0/1 via 10.30.1.17 dev tun1
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.84
So there's no change in ip address or anything odd happening as far as I can tell with routing when opening or closing the different VPNs.
I'm at a loss as to why bind.so
seems to be having no effect. There is no output to the terminal to show whether its successful or not, and I'm not sure where to look for a log, if it is outputting anything (the output in the terminal is for the command, i.e. get_iplayer).
Obviously I could run cron jobs/scripts to open and close the VPNs to allow me to run get_iplayer successfully/through the UK VPN, but I would much rather keep both VPNs open, have all of my traffic going through the tun0
interface and only use tun1
for get_player when I need to with bind.so
.
Can anyone provide any help? If we cannot solve this issue, some help towards writing specific routing tables or rules for the get_iplayer process would be great.
Thanks.