HideMyAss VPN Part 1

So you have a vpn account but its a pain in the arse to change servers when you want to change between iplayer and hulu. Below i describe the config i used to set up my system to have multiple vpns depending on the destination. in the below example i will use iplayer i.e. http://www.bbc.co.uk

Ok i’ll start by saying im using arch linux so instructions will be for that, if your stuck on a different distro, leave comments and ill try to help

First install nc, ipcalc, dnsutils, openvpn, curl and unzip (because for some reason hide my ass uses zip)

pacman -S openvpn curl unzip nc ipcalc dnsutils

Get a base uk file, selecting a location from the countries file

wget http://vpn.hidemyass.com/vpnconfig/countries.php -O - | sed -e 's/ /+/g' -e s'/+$//'
wget http://vpn.hidemyass.com/vpnconfig/client_config.php?win=1&loc=UK,+Greater+Manchester,+Manchester+(LOC1+S2) > /etc/openvpn/openvpn-uk.cfg

Add the option `route-nopull` to the config. This ignores the default route sent by the hidemyass servers.

Now to get a list of prefixes associated with http://www.bbc.co.uk.

First get a starting address:

dig +short www.bbc.co.uk | tail -1

Then the AS number:

echo origin | nc asn.shadowserver.org 43
2818 | | BBC | UK | BBC.CO.UK | BBC

Then the associated prefixes

echo "prefix 2818" |  nc asn.shadowserver.org 43


echo origin `dig +short www.bbc.co.uk | tail -1` | nc asn.shadowserver.org 43 | awk '{print "prefix",$1}' |  nc asn.shadowserver.org 43

now we need to convert

i used the following but im sure there is a better way:

echo -en "route " ; ipcalc --nocolor --nobinary |  awk '/(Address|Netmask)/ {printf "%s ", $2}' ; echo

Adding it together:

echo "route-nopull"; echo origin `dig +short www.bbc.co.uk | tail -1` | nc asn.shadowserver.org 43 | awk '{print "prefix",$1}' |  nc asn.shadowserver.org 43 | while read line ; do  echo -en "route " ; ipcalc --nocolor --nobinary ${line}  |  awk '/(Address|Netmask)/ {printf "%s ", $2}' ; echo ; done >> /etc/openvpn/openvpn-uk.cfg

Finally fetch the hidemyass files:

wget https://vpn.hidemyass.com/linux.zip

unzip the linux.zip file and copy the keys directory to /etc/openvpn/keys. Update the ca, cert and keys parameters in  /etc/openvpn/openvpn-uk.cfg changing the directory to /etc/openvpn/openvpn-uk.cfg

unzip linux.zip
mv keys /etc/openvpn/
sed -i 's/\.\/keys\//\/etc\/openvpn\/keys\//g' /etc/openvpn/openvpn-uk.cfg

start openvpn and enter your username and password.

openvpn /etc/openvpn/openvpn-uk.cfg

Now traffic destined for the bbc will originate from a uk server. you can now create another config using to set up a tunnel for the us which is only valid for hulu. e.g.

wget http://vpn.hidemyass.com/vpnconfig/client_config.php?win=1&loc=USA,+New+York+(DC2+S1) > /etc/openvpn/openvpn-uk.cfg
echo "route-nopull"; echo origin `dig +short www.hulu.com | tail -1` | nc asn.shadowserver.org 43 | awk '{print "prefix",$1}' |  nc asn.shadowserver.org 43 | while read line ; do  echo -en "route " ; ipcalc --nocolor --nobinary ${line}  |  awk '/(Address|Netmask)/ {printf "%s ", $2}' ; echo ; done >> /etc/openvpn/openvpn-us.cfg
openvpn /etc/openvpn/openvpn-us.cfg

in the next part i show how to make these vpns into a daemon using daemon tools

2 Responses to “HideMyAss VPN Part 1”

  1. September 25, 2014 at 10:30 pm

    Have you ever considered writing an ebook or guest authoring on other websites?
    I have a blog based upon on the same subjects you discuss and would love to have you
    share some stories/information. I know my viewers would value your
    work. If you are even remotely interested, feel free to send
    me an e mail.

Leave a Reply to socks Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: