{"id":49,"date":"2017-05-29T11:06:10","date_gmt":"2017-05-29T10:06:10","guid":{"rendered":"https:\/\/www.philroche.net\/?p=49"},"modified":"2017-05-29T11:06:10","modified_gmt":"2017-05-29T10:06:10","slug":"creating-a-vpn-server-on-aws-using-pivpn","status":"publish","type":"post","link":"http:\/\/wp.philroche.net\/2017\/05\/29\/creating-a-vpn-server-on-aws-using-pivpn\/","title":{"rendered":"Creating a VPN server on AWS using PiVPN"},"content":{"rendered":"
One of the streaming services I use called NowTV<\/a>\u00a0recently launched an Irish service alongside their UK service which I was using. The Irish service costs _double_<\/strong>\u00a0\u00a0the cost in UK. They have also begun geoblocking all Irish users and also users of VPN Services like ExpressVPN<\/a> and PrivateInternetAccess<\/a> from using the UK service.<\/p>\n To get around this I decided to set up my own VPN server on AWS in their London datacenter<\/a> to get around the geoblocking.<\/p>\n The easiest way I have found to set up a VPN server is to use PiVPN<\/a> (http:\/\/www.pivpn.io\/<\/a>) which was designed for use on Raspberry Pi but can be installed on any Debian based machine.<\/p>\n There has been a few recent guides<\/a>\u00a0on how to install PiVPN but this one focusses on installing on AWS.<\/p>\n A prerequisite for this guide is that you have an AWS account<\/a>. If this is your first time using AWS then you can avail of their free tier<\/a> for the first year which means you could have the use of a reliable VPN server free for a whole year. You will also need an SSH keypair<\/a>.<\/p>\n The steps are as follows:<\/p>\n Log in to your AWS account and select the London region, also referred to as eu-west-1.<\/p>\n <\/a><\/p>\n Create a new security group for use with your VPN server.<\/p>\n <\/a><\/p>\n This new group sets up the firewall rules for our server and will allow only access to port 22 for SSH traffic and UDP port 1194 for all VPN traffic.<\/p>\n <\/a><\/p>\n Launch a server instance<\/p>\n <\/a><\/p>\n We will choose Ubuntu Server 16.04 as it is a Debian based distro so PiVPN will install.<\/p>\n <\/a><\/p>\n Choose the t2.micro instance type. This is the instance type that is free tier elligible.<\/p>\n <\/a><\/p>\n Leave instance details default<\/p>\n <\/a><\/p>\n Leave storage as the default 8GB SSD<\/p>\n <\/a><\/p>\n No need to add any tags<\/p>\n <\/a><\/p>\n Choose the security group we previously created.<\/p>\n <\/a><\/p>\n Review settings – nothing to change here.<\/p>\n <\/a><\/p>\n Click Launch and specify either a new SSH keypair or an existing SSH key pair. I have chosen an existing pair which is called “philroche”.<\/p>\n <\/a><\/p>\n Check the checkbox abount key access and click Launch Instances. Your instance will now launch.<\/p>\n <\/a><\/p>\n Click View Instances and once state has changed to running note the IPv4 Public IP. You now have an instance on Ubuntu Server running on AWS in their London datacentre.<\/p>\n <\/a><\/p>\n SSH in to your new server using the private key from the pair specified when launching the server.<\/p>\n substituting %IPV4IPAddress% for the IP address of your server<\/p>\n <\/a><\/p>\n Once logged in update the packages on the server.<\/p>\n <\/a><\/p>\n Start the PiVPN installer.<\/p>\n For more detail on this, see\u00a0http:\/\/www.pivpn.io\/#tech<\/a><\/p>\n <\/a><\/p>\n You are then guided through the process of installing all the required software and configuring the VPN server:<\/p>\n <\/a><\/p>\n <\/a><\/p>\n <\/a><\/p>\n <\/a><\/p>\n Choose the default ubuntu user.<\/p>\n <\/a><\/p>\n <\/a><\/p>\n We do want to enable unattended upgrades of security patches.<\/p>\n <\/a><\/p>\n Choose UDP as the protocol to use.<\/p>\n <\/a><\/p>\n Choose the default port 1194.<\/p>\n <\/a><\/p>\n <\/a><\/p>\n Create a 2048 bit encryption key.<\/p>\n <\/a><\/p>\n <\/a><\/p>\n Choose to use your servers public IP address.<\/p>\n <\/a><\/p>\n Choose whichever DNS provider you would like to use. I chose Google.<\/p>\n <\/a><\/p>\n Installation is now complete \ud83d\ude42<\/p>\n <\/a><\/p>\n Choose to reboot the server.<\/p>\n <\/a><\/p>\n <\/a><\/p>\n Once the server has rebooted, checking the AWS dashboard for it’s status,\u00a0SSH back in to the server.<\/p>\n Now we need to configure a VPN profile that we can use to connect to the VPN server.<\/p>\n The easiest way to do this is to use the \u200b\u200b\u200b\u200bpivpn command line utility.<\/p>\n <\/a><\/p>\n This will guide you through the process of creating a profile. Make sure to use a strong password and note both the profile name and the password as you will need these later.<\/p>\n <\/a><\/p>\n Set up is now complete so you can logout.<\/p>\n <\/a><\/p>\n The only thing left to do is to download the profile you created from the server so that you can use it locally.<\/p>\n substituting %IPV4IPAddress% for the IP address of your server and\u00a0%PROFILENAME% with the name of the profile you created.<\/p>\n This will download the .ovpn file to your current directory.<\/p>\n <\/a><\/p>\n Once downloaded you can import this to your VPN client software of choice.<\/p>\n I used the profile on a small Nexx WT3020<\/a> I had with OpenWRT<\/a> installed. I connect this to my NowTV box so I can continue to use NowTV UK instead of the overpriced NowTV Ireland.<\/p>\n\n
1. Start up an instance of Ubuntu Server\u00a0on AWS in the London region<\/h3>\n
2. Install PiVPN<\/h3>\n
ssh -i ~\/.ssh\/philroche ubuntu@%IPV4IPAddress%<\/pre>\n
sudo apt-get update<\/pre>\n
curl -L https:\/\/install.pivpn.io<\/a> | bash<\/pre>\n
pivpn add<\/pre>\n
3. Download VPN configuration files for use locally<\/h3>\n
scp -i ~\/.ssh\/philroche ubuntu@%IPV4IPAddress%:\/home\/ubuntu\/ovpns\/%PROFILENAME%.ovpn .<\/pre>\n