28
Jan
12

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
212.58.244.67

Then the AS number:

echo origin 212.58.244.67 | nc asn.shadowserver.org 43
2818 | 212.58.224.0/19 | BBC | UK | BBC.CO.UK | BBC

Then the associated prefixes

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

or

echo origin `dig +short www.bbc.co.uk | tail -1` | nc asn.shadowserver.org 43 | awk '{print "prefix",$1}' |  nc asn.shadowserver.org 43
132.185.128.0/20
132.185.144.0/20
132.185.240.0/24
132.185.0.0/16
212.58.224.0/19

now we need to convert
from:
132.185.240.0/24
to:
route 132.185.240.0 255.255.255.0

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

echo -en "route " ; ipcalc --nocolor --nobinary 132.185.240.0/24 |  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

Advertisements

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

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: