Intro
Set up a VPN (in this case Private Internet Access and start & bind rtorrent
on that tunnel
Inspired by: http://www.ichimonji10.name/blog/1/
Note that only rtorrent
traffic will be routed through the tunnel, everything else goes the normal way.
Prerequisite
Make sure that you have configured a routing table piatunnel
on your system:
echo 200 piatunnel >> /etc/iproute2/rt_tables
Get the PIA openvpn.zip, extract it and make sure that the certs etc. are in the same directory as ; same goes for
vpn-up/down.sh
. Note that is derived from the sweden config file provided in that zip from pia.
start it
establish the vpn
sudo openvpn pia_swe.ovpn
start rtorrent
with the bind option
./rtorrentvpnip.sh
Based on the configured tunnel, in example tun1
, get the local IP for the established VPN and start rtorrent
with the -b
(bind) parameter to bind to the local VPN IP.
Read further
https://wiki.archlinux.org/index.php/RTorrent
Todo
- The openvpn resets itself every now and then, in this case the IP which rtorrent has been bind to is not valid anymore. Either re-execute
or implement a script that tells rtorrent to bind to another IP
- update
to figure out the openvpn tunnel itself
- enable PIA port-forwarding and configure rtorrent use the fwd'd-port
I have one important thing to add :)
I just spent too much time to find out that the env var "ifconfig_remote" is ONLY set if "you're using 'dev tun' and
are not using 'topology subnet'" (see: https://groups.google.com/forum/#!topic/openvpn-users/JT-f1XzAFQs)
If your VPN provider is using 'topology subnet' your up-script keeps failing.
A simple way to fix this, is to calculate the first possible IP adress of your given subnet and set the ifconfig_remote variable to this IP before you execute the rest of the script.
It is not fail-prove, as the VPN gateway does not have to be the first IP, but in most cases it should be.