Turn your Raspberry Pi into a VPN Server

Due to its low power consumption, the Raspberry Pi is perfect to act as a VPN Server (Virtual-Private-Network). With a VPN you can securely connect to your home network when you’re on the go, either simply to browse securely or to access the files in your network. In this tutorial you will learn how to turn your Raspberry Pi into a VPN.

Requirements

  • Of course you need a Raspberry Pi, which you can purchase here for about 40€.
  • HDMI or composite cable: You need to connect your Raspberry Pi to a monitor during the instalation process. Afterwards you don’t need a monitor anymore (AmazonBasics HDMI-Kabel).
  • An 8GB Class 10 SD card or better and a SD-card reader, if you don’t have a built in SD card reader you need to get an extern SD card reader.
  • USB-Keyboard and mouse
  • An Ethernet cable – to ensure best performance you should prefer a wired internet connection.
  • A micro USB-power supply - at least 700mA at 5V. Mobile chargers should work, especially iPhone/iPad chargers.
  • You need to sign up for a free LogMeIn account because we are using LogMeIn Hamachi to create our VPN. We need this account because it saves us from messing around with port forwarding, getting a static IP address and so on.

Step 1 – Set up and configure your Raspberry Pi

You should know how to plug in all the wires into the Raspberry Pi ;)

vpn

If you’re not in the UK you need to change your keyboard layout to your country’s layout during set-up, you’ll need several special characters, or change the layout afterwards using:
sudo dpkg-reconfigure keyboard-configuration

Follow the promp to your country’s layout and then restart your Raspberry Pi.

sudo reboot

Another way would be to reload the keymap without rebooting:

invoke-rc.d keyboard-setup start

 Step 2 – Update the Raspberry Pi and Install Hamachi

At first we need to update the packages because some of the packages needed may not be installed in your image.

sudo apt-get update

Install LSB (Required by Hamachi)

sudo apt-get install --fix-missing lsb lsb-core

Show some patience during the installation and download the latest Hamachi build for Linux afterwards.

sudo wget https://secure.logmein.com/labs/logmein-hamachi_2.1.0.86-1_armel.deb

If you get errors grabbing the Hamachi for Linux download, check the download page on LogMeIn to verify the version number (e.g., 2.1.0.86-1) and change it in the filename if necessary.

Install Hamachi by typing

sudo dpkg -i logmein-hamachi_2.1.0.86-1_armel.deb

into your shell.

Step 3 – Hamachi Configuration on the Raspberry Pi

Now you need to get Hamachi up and running on your Raspberry Pi and on your client devices.

First, connect your Raspberry Pi to your LogMeIn account and create a Hamachi network.

sudo hamachi login

sudo hamachi attach [YOUR_LOGMEIN_EMAIL]
sudo hamachi set-nick [NICKNAME_FOR_YOUR_PI]

On your client machines, go to LogMeIn and head over to “My Networks”. If everything went well you should see your Raspberry Pi trying to connect and create a new network. Give the Pi the right to create the network and note the 9-digit network ID.

Back on your Raspberry Pi enter:
sudo hamachi do-join [NETWORK_ID]

You might be asked for your LogMeIn password and approve the requested access to the network on the client. After this step the Pi is part of the Hamachi VPN. Look for the Pi’s IP-address in the VPN at LogMeIn and remember it.

Start the SSH Server to connect and control your Pi remotely.

sudo /etc/init.d/ssh start

Step 4 – Install Hamachi on your Clients

Almost done! For the Windows, Mac, or Linux computers you also want to connect to the VPN, you’ll need to install the Hamachi client from the download page.

After installation, you can join the VPN (Network > Join) and SSH into the Raspberry Pi or access network files, etc. (In Windows, use a tool like Putty or in Mac/Linux use Terminal to SSH, using the Raspberry Pi’s IP address assigned by Hamachi in the server field).

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>