Raspberry Pi VPN Access Point
In this Raspberry Pi VPN access point tutorial, we will be exploring how to setup a VPN for use with a WiFi Access point. This tutorial is pretty straight forward and once setup you can leave it alone with only needing do maintenance if something goes wrong.

This tutorial provides a quick and easy way of running any device you want through a VPN even if it doesn’t support any VPN software. As all you need to do is connect that device to your Raspberry Pi wireless access point and all its traffic will be automatically routed through a VyprVPN tunnel.

This tutorial builds upon our previous tutorial on a wireless access point but makes one big change, and this is to route all traffic through a VPN. This is essentially a VPN router and incredibly easy to set up, you will need to first run through the first tutorial that I just linked to.

For our tutorial, we will be showing you how to set this up utilizing the VyprVPN service. Whilst testing out various VPN providers for this tutorial we found it to be the most stable, and fastest VPN, all while being cheap (Out of the ones we tried).

If you rather connect to the Raspberry Pi from outside your network and use that as a VPN then I have a pretty easy to follow Raspberry Pi VPN tutorial you should take a look at.

Please note that you will require a VyprVPN account to follow this tutorial, you can sign up to VyprVPN over at their website.

Equipment List

Below are all the bits and pieces that I used for this Raspberry Pi VPN access point server tutorial, there is nothing super special that you will need to be able to complete this.


Raspberry Pi 2 or 3

Micro SD Card or a SD card if you’re using an old version of the Pi.

Wifi dongle (The Pi 3 has WiFi inbuilt)

Ethernet Connection

VyprVPN Subscription


Raspberry Pi Case

Setting up the Wireless Access Point

To set up our VPN Access Point you will first had to of followed our Wireless Access Point tutorial, as this will setup your Raspberry Pi perfectly for this tutorial.

For this tutorial, we will be utilizing the VPN service, VyprVPN. We found this to be the most robust VPN that also provided us with the fastest VPN service out of the several we tried for this tutorial, it is also one of the cheapest around. If you haven’t already then you will need to sign up for VyprVPN.

For the VPN itself we will be utilizing the OpenVPN software, luckily for us VyprVPN offers full support for the OpenVPN protocol and provides us with the .opvn files required to get it up and running.

1. Before we get started with setting up our VPN Access Point, lets first make sure we have the latest packages by running the following two commands.

sudo apt-get update
sudo apt-get upgrade

2. Now that we are fully up to date we can install the OpenVPN software that we will rely on. We can do that by running the following command in the terminal.

sudo apt-get install openvpn -y

3. With OpenVPN now installed we need to reboot your Raspberry Pi, this will basically ensure us that the tunnel adapter will be installed. Reboot the Raspberry Pi with the following command.

sudo reboot

4. Now let’s jump to the openvpn directory where we will be storing all the stuff we need to get VyprVPN up and running. Let’s jump to the directory with the following command.

cd /etc/openvpn

5. Now we are in the configuration directory we will now download our VyprVPN OVPN files. These are what we will load to make a connection to Vypr’s network. Run the following code to grab the zip file.

sudo wget -O vyprvpn.zip https://pimylifeup.com/out/vyprovpnfiles

6. With the zip file now on our Raspberry Pi we need to extract it so we can access all the files. We can easily extract this by running the following command in the terminal.

sudo unzip vyprvpn.zip

7. Now we can check out all the .OVPN files by changing into the newly generated directory, in here take note of the location you want to connect into as you will need to specify this in a later command.

cd vyprvpn

8. Now use the following command to list all of the .ovpn files in here. Take note of the filename for the location you want to use, for instance if we wanted to connect to the San Francisco in the United States we would take note of “USA – San Francisco.ovpn”


9. With that now done we need to now create our authorization file, this is basically just a file that will keep your username and password for your VyprVPN service. Begin creating the file by running the following command.

sudo nano /etc/openvpn/auth.txt

10. Now add your username and password to this file like shown in our example below. We will make OVPN load this file to log in into VyprVPN.
To begin editing the first of these two files run the following command.


Now we can save and quit out of the file by pressing Ctrl+X then pressing Y and then Enter.

11. With that done we can now test to make sure that OpenVPN is actually making a successful connection to VyprVPN.

To do this we will be running the following command, make sure to replace the .ovpn file with the location you want to use. For our example, we will be using “USA – San Francisco.ovpn”

sudo openvpn --config "/etc/openvpn/vyprvpn/USA - San Francisco.ovpn" --auth-user-pass /etc/openvpn/auth.txt

This will output a fair bit of text as it makes the connection, the main text you will want to look for is something like below. If you get this it should mean that you have now made a successful connection to VyprVPN’s servers.

/sbin/ip route add via
/sbin/ip route add via
/sbin/ip route add via
Initialization Sequence Completed

12. With our Raspberry Pi VPN router not working correctly we need to utilize iptables to reroute the wlan0 connection through to our tunnel, rather than through to the ethernet like we did in our wireless access Point tutorial.

Before we do this though we will have to flush out our current iptables, we can do that by running the next three commands.

sudo iptables -F
sudo iptables -t nat -F
sudo iptables -X

13. Now let’s finally install our new iptables by running the following three commands, this will basically tell it to forward all our wlan0 traffic over to the tunnel connection.

sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
sudo iptables -A FORWARD -i tun0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o tun0 -j ACCEPT

14. With that done, let’s now save our iptables to overwrite the old rules we set up in our wireless access point tutorial. To do this run the following command.

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

15. With our IPTables now set up, we need to move onto getting the VPN connection to be automatically started up when the Raspberry Pi starts. We can do this by first editing the rc.local file.

sudo nano /etc/rc.local

16. Now add the following to the file, just above exit 0. Again, make sure you replace your selected location “USA – San Francisco.ovpn” with the VyprVPN location you intend on using.

sleep 5
cd /etc/openvpn
sudo openvpn --config "/etc/openvpn/vyprvpn/USA - San Francisco.ovpn" --auth-user-pass /etc/openvpn/auth.txt

Now we can save and quit out of the file by pressing Ctrl+X then pressing Y and then Enter.

17. You should now be able to connect to your Raspberry Pi’s wireless access point and be automatically connected through the VPN, one of the best ways to test this is to connect with a random device then check your IP Location by checking the top bar at VyprVPN’s website.

Assuming everything is now working correctly it is best to restart your Raspberry Pi, this ensures that everything will be now running fresh and ensures that the wireless access point and the VPN will both start up correctly.

sudo reboot

Hopefully by now you should have a fully operational wireless access point that will route all its traffic through our OpenVPN tunnel to the VyprVPN service. This should leave you with a stable and fast VPN connection and an easy way to switch to a more secure connection.

If you come across any issues or have some feedback related to this Raspberry Pi VPN access point tutorial, then please don’t hesitate to leave a comment below.

Affiliate link disclaimer: All the products I mention on this website I have personally purchased and used at least once. Some of the links on this website are affiliate links that earn me a small commission whenever a sale is made.

The Raspberry Pi Crash Course

The Raspberry Pi Crash Course

Enter your email address below to get the

Raspberry Pi crash course delivered straight to your inbox

Please check your inbox for a confirmation email!