So, it’s been a little bit over half a year since I published the article about how to set up an always-on seed-box/VPN using Squid, Sick-Beard, and Deluge. A little bit has changed since then.
First, I no longer use IPVanish. I had an issue with them where they double charged me for a month, and gave me a little bit of a run-around trying to resolve it. Specifically, after contacting their support, they told me that only one of the transactions was successful, the other failed. My PayPal account and my financial institute disagreed. Then they told me I’d have to take it up with PayPal. I took this as a sign that it was time to switch providers. To their (mild) credit, after pressing them for more information, they just went ahead and reversed the charge. Unfortunately for them (not that they probably care that much), I had already switched providers. I now use HideMyAss Pro VPN (disclosure: that’s an affiliate link).
In addition to having switched to HideMyAss Pro VPN, I’ve updated the infrastructure in a couple of different ways to be a bit easier to work with and a bit more flexible.
First, there’s no longer a
ipvanish config file, since that’s been replaced with a
hidemyass file. But that’s been symlinked to
ln -s hidemyass vpn. That file, just as with the previous one for
ipvanish contains the necessary config bits to connect to HideMyAss. The
options.pptp file isn’t referenced, so I just left that alone and it’s ignored. I updated
chap-secrets to contain the credentials that I use for HideMyAss. Of note, HideMyAss uses a different password for PPTP and L2P connections than your normal password. Find that in your dashboard.
ipvanish.service unit for
systemctl has been renamed to
vpn.service so that it’ll stand up semantically to provider changes. It’s also been updated to remove any
ipvanish references in favor of the more generic term
vpn. It’s also not directly calling
pon anymore to turn the VPN on and off. I created a couple of scripts to manage this for me.
togglevpn.sh script is what’s called by the
vpn.service. It just passes
off just as were passed directly to
pon. That script first calls
update_vpn_to_fastest_ip.sh which calls
fastest_ip.py to retrieve the IP of the fastest VPN node that’s near me (this is just a local-ish subset of the IPs that HideMyAss provides), and updates the
/opt/ppp/peers/vpn link (which points to
/opt/ppp/peers/hidemyass) to use that IP. After that,
pon is called to turn the VPN on. Finally, Squid is updated with
update_squid_outgoing_ip_to_interface.sh and then restarted.
#!/bin/sh case "$1" in on) echo "Finding fastest IP..." /opt/update_vpn_to_fastest_ip.sh sleep 2s echo "Turning VPN on..." /usr/bin/pon vpn sleep 2s /opt/update_squid_outgoing_ip_to_interface.sh ppp0 sleep 2s ;; off) echo "Turning proxy off..." /usr/bin/poff vpn sleep 2s /opt/update_squid_outgoing_ip_to_interface.sh eth0 sleep 2s ;; restart) $0 off $0 on ;; esac systemctl restart squid
#!/usr/bin/python2.7 # Finds the fastest Seattle IP for HMA import sys import re from subprocess import Popen, PIPE from threading import Thread ips = [ "126.96.36.199", "188.8.131.52", "184.108.40.206", "220.127.116.11", "18.104.22.168", "22.214.171.124", "126.96.36.199", "188.8.131.52", "184.108.40.206", "220.127.116.11", "18.104.22.168" ] fastest_ip = "" lowest_ping = 100 for ip in ips: p = Popen(['/usr/bin/ping', '-c 1 ', ip], stdout=PIPE) time = str(p.stdout.read()) m = re.search("time=([0-9.]+) ms", time) if m: ms = float(m.group(1)) if ms < lowest_ping: lowest_ping = ms fastest_ip = ip #print("%s is alive. round trip time: %f ms" % (ip, ms)) #print("Fastest ip is %s at %s" % (fastest_ip, lowest_ping)) print(fastest_ip)
#!/bin/bash ipaddy=`/opt/fastest_ip.py` echo "Updating VPN to $ipaddy..." sed -i -e "s/^pty.*/pty \"pptp $ipaddy --nolaunchpppd\"/g" /etc/ppp/peers/vpn</pre>
#!/bin/bash case "$1" in ppp0) ipaddy=`ip addr | grep ppp0 | grep inet | cut -d' ' -f6` ;; eth0) ipaddy=`ip addr | grep eth0 | grep inet | cut -d' ' -f6 | sed 's/\/24//g'` ;; esac echo "Updating squid to $ipaddy..." sed -i -e "s/^tcp_outgoing_address.*/tcp_outgoing_address $ipaddy/g" /etc/squid/squid.conf</pre>
All in all this works rather well for me. I have occasional issues with ppp0 dropping out. I’m not sure if this is my problem or theirs, but I just log in and
systemctl restart vpn and I’m back to the races. I’ve considering setting up a cron job to do this for me every hour or so, but it’s not been that much of a problem.