Build Your Own Raspberry Pi VPN Server - Pi My Life Up
Build Your Own Raspberry Pi VPN Server - Pi My Life Up
Save as PDF
If you buy through our links, we may earn an affiliate commission. Learn More.
I will also go into setting up various things you must do to ensure that
your connection is as secure as possible by setting up encryption keys.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 1 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
LATEST VIDEOS
VPN’s are an incredibly useful network tool that can allow you to gain
access to encrypted and secure internet traffic even when you are
utilizing public Wi-Fi.
For example, if you had a network attached storage server that you
wanted to access while away, then a VPN server will be extremely handy
in achieving a secure way to access it.
Search … Search
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 2 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Equipment List
Below are all the bits and pieces that I made use of for this Raspberry Pi
VPN server tutorial, there is nothing super special that you will need to be
able to complete this.
Recommended
Raspberry Pi ( Amazon )
Optional
Video
In the video below, we walk you through the process of setting up a VPN
on our Raspberry Pi using the OpenVPN software.
If you run into any issues, be sure to check out the written version of our
VPN guide below.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 3 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Before we get started with setting up the Raspberry Pi VPN server there
are a few things we must go over to ensure that you are ready to set it up
and use it.
Firstly, for this tutorial, it’s important to know that I am using a clean
version of Raspbian. If you haven’t installed it and would like to learn how
then my guide on installing Raspbian is extremely handy if you’re new to
all this.
For starters, make sure you actually do need a VPN before you start
setting this up, as it can act as a gateway into your home network.
If you do intend on using a VPN make sure all the computers on your
home network are secure, and that you aren’t sharing anything within
your local network that you wouldn’t want someone gaining access to.
It’s important to decide whether you are going to make use of a static IP
address or a dynamic IP address, setting up a VPN for a static IP address
is a rather simple process and requires no extra work.
However, if you want to utilize a dynamic IP address, you must make use
of a dynamic DNS service.
If you choose to go down the dynamic DNS service route, then you
should decide whether you want to make use of your own domain name
or a free one.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 4 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
If you want to make use of your own domain name, then you can use a
service like CloudFlare, if you’re going to make use of a free subdomain
then a service such as no-ip.org will be useful for you.
You can check out our guide on setting up your Raspberry Pi for Dynamic
DNS for more information.
Remember the domain name that you set up for either Cloudflare or no-
ip.org as you will need this later on in the tutorial.
The third important thing that you will need to get done before you start
setting up your Raspberry Pi is to port forward for the OpenVPN
software.
The default port you need to forward is 1194 . Remember the port you
set as you will need this later on in the tutorial. The protocol you will have
to make use of for this port is UDP .
Luckily for us, there is a much easier way to set up a Raspberry Pi VPN
server thanks to an install script called PiVPN, this handles all the grunt
work for setting up a VPN and reduces the potential for making mistakes.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 5 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Before we get started, we should first change the password of the default
pi user, this is to ensure if someone managed to gain access to your VPN
they wouldn’t be able to access your Raspberry Pi easily.
Terminal $ Copy
passwd
Terminal $ Copy
3. Once you have run the above command, you should be met with the
following screen. This screen will feature some text telling you that you
are about to install OpenVPN.
To proceed to the next screen, you need to press the ENTER key.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 6 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
4. The next screen explains that you will need to set up a static IP
address for your VPN.
This is so that when the Raspberry Pi is restarted, it will try and use the
same IP address. If the local IP changes, you could potentially lose
access to your VPN.
5. You will now be asked if you are using a DHCP reservation on your
router.
If you don’t know what DHCP reservation is or how to use it, select <No>
to continue.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 7 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
If you are unhappy with the IP address displayed on this page, then
select <No> .
7. This screen warns you that there is a chance your router will assign
the IP address to another device.
You can use DHCP reservations to avoid this. However, most routers are
smart enough to prevent the problem.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 8 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
8. This screen explains that we will need to set a user that will own the
OpenVPN configuration files.
9. We will be presented with a list of users who can own our Raspberry
Pi’s VPN config files.
In this tutorial, we will be making use of the pi user. If you want to use
another user, use the ARROW keys and SPACEBAR to select it.
Once you are happy with your selection, press the ENTER key to
continue.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 9 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
10. You will now be asked to select what type of VPN you want to install
on your Raspberry Pi.
For this guide, we will be using OpenVPN on our Raspberry Pi (1.). Use
the ARROW keys and the SPACEBAR to select it.
Once you have OpenVPN selected, press the ENTER key to continue (2.).
10. You can now decide whether you want to customize the installation
of OpenVPN on your Raspberry Pi.
The setting chosen by the PiVPN team is best for most users. However,
you can modify these if you like.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 10 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
For our guide, we are going to stick with the default settings.
11. Now we will be selecting the port that OpenVPN will operate
through.
For this tutorial, we are going to stick with the default port of 1194 . You
should only change the port if you have a good reason to.
Once you have defined the port, select <Ok> and press ENTER .
14. You will be asked to confirm the port that you set for your OpenVPN
installation
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 11 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
If you are happy with the port you have chosen, then select <Yes> to
continue.
15. The next step is to select a DNS provider. A DNS provider is what
resolves a URL like https://pimylifeup.com into an IP address.
To select Cloudflare or another DNS provider, you will need to use the
ARROW keys (1.).
Once you are hovering over the DNS provider you want, press the
SPACEBAR key to select it.
Once you are happy that you have made the right choice, you can press
the ENTER key to proceed.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 12 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
16. You will need to decide whether you want to make use of your public
IP Address or a DNS name.
As we are using a static public IP address, we will stick with using our
public IP address for this guide.
You can change between options by using the ARROW keys. Once you
have the one you want, press the SPACEBAR key to select it.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 13 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
17. This next step is just explaining to you that the PiVPN script is about
to generate both the HMAC key and the server key.
These keys are part of what makes up the encryption part of your
Raspberry Pi’s VPN.
Press the ENTER key to proceed to the actual configuration page for this
setting.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 14 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Leaving this feature switched off can pose a significant security risk to
your Raspberry Pi’s VPN and potentially your home network.
While there are still a couple more things you will need to complete to
allow connections, you are now about 90% through this setup guide.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 15 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Select the <Yes> option to the following two screens by pressing the
ENTER key.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 16 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Terminal $ Copy
On this screen, you will need to enter a name for the client, and this
name will act as an identifier so you can differentiate between different
clients.
It will also ask you to set a password for the client, and it is important to
make this something secure and not easy to guess as this will secure the
encryption key.
So, if someone can guess the password easily, it severely reduces the
security of your VPN.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 17 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Once you press enter to these, the PiVPN script will tell Easy-RSA to
generate the 2048-bit RSA private key for the client, and then store the
file into /home/pi/ovpns .
Make sure you keep these files safe as they are your only way of
accessing your VPN.
2. Now that our new client has been set up for OpenVPN with our
passphrase we will now need to get it to the device that we intend on
connecting from.
The easiest way to do this is to make use of SFTP from within your home
network.
Make sure you have a program such as FileZilla that can handle SFTP
connections installed before continuing with this tutorial.
If you don’t have you Pi’s local address use the command hostname -I
in the terminal.
Once you have entered your IP address, Username and Password, press
the quick-connect button.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 18 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
3. Once you have successfully logged in, we need to look for the ovpns
folder, as this is where the file we need will be located.
4. Now, all we need to do is drag the .ovpn file you want to somewhere
safe on your computer. This file contains the data that we will need to
connect to the VPN so keep this file safe.
It is also the only way someone could potentially gain access to your
VPN, so keeping the passphrase and the file secure is incredibly
important.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 19 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
5. Now we have the .opvn file on our device we can use this to make a
connection to our VPN.
The only thing it does not contain is your passphrase, so you will need to
enter this when you connect to the VPN.
The client we are going to use is the official OpenVPN client, and you can
obtain this from their official OpenVPN website.
Download and install this client, on its first run it will automatically
minimize to the taskbar, right click on the icon, then select “Import file…”
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 20 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Once you have found it, double-click the file to import into the
OpenVPN client.
7. You should now be presented with a dialog telling you the file has
been successfully imported into OpenVPN.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 21 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
9. Now the OpenVPN client will attempt to read the data located in the
.opvn file.
Since we have a passphrase set, it will now ask for you to enter the
passphrase you set earlier on in this tutorial.
Once you are certain you have entered the correct passphrase, click
the “OK” Button.
10. The OpenVPN client will now attempt to connect to your Raspberry
Pi’s VPN server. If the OpenVPN icon turns to a solid green, then it means
that you have successfully connected into your VPN.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 22 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
However, if it turns yellow and fails to turn green after 60 seconds that
means something is causing the connection to fail.
It is easiest to google your router’s model number to try and find help on
any issues you may face with port forwarding.
Some ISP’s (Internet Service Provider) also block specific ports, so it’s
best to check that your ISP is not blocking the port you plan on using.
If you are using a dynamic DNS service, then make sure that the service
is being correctly updated with your latest IP address if the IP address
has changed, but the DNS setting hasn’t then it will cause the connection
to fail.
Hopefully, by now, you will have a fully functional VPN that you’re able to
connect to successfully.
1. If for some reason you want to remove your VPN from your Raspberry
Pi you can simply utilize the following command on it.
This command will utilize the pivpn software to uninstall the VPN tunnel.
Terminal $ Copy
I hope that this tutorial has shown you how to set up a Raspberry Pi VPN
Server and that you haven’t run into any issues. It’s certainly a great
project for anyone who wishes to set up a cheap always-on VPN
network.
If you have some feedback, tips or have come across any issues that you
would like to share, then please don’t hesitate to leave a comment below.
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 23 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Email*
Subscribe
Recommended
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 24 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Leave a Reply
Your email address will not be published. Required fields are marked *
Comment
Name * Email *
Post Comment
60 Comments
Can this be used for safe browsing from home? At first I thought I would
be able to cancel my VPN subscription, but I don’t see how it would
work, since there’s nothing on the other side to decrypt my browsing
traffic.
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 25 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Hi Wdixon,
This would only really work for that situation if you set up your VPN
server in another location that wasn’t your home network. You
would more set this up for trying to access stuff on your local home
network when you are out and about. You would probably still be
best to stick with your VPN subscription.
Kind regards,
Emmet
Reply
Thanks Gus. I have just went through your instructions and have it
working great on a Raspberry Pi 4B. I’m getting download speeds of
400+Mbps (my normal connection is 900Mbps) so that is really great. I
chose WireGuard instead of OpenVPN though.
Reply
hello,
i have followed the steps to configure my no-ip.org free subdomain.
But in the setup on step 15, there is no option for no-ip.org.
Can someone please tell me how i would configure this?
Thanks!!
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 26 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Hi Tom Wetzels,
You will be safe picking any of those five options. These are just for
resolving DNS requests and not for handling your domain name
itself.
Cheers,
Emmet
Reply
worked like a charm! Thank you for this! Only part I replaced in this
tutorial is the use of filezilla, with scp from CLI.
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 27 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
GREAT WORK!
Reply
On the computer is easy, just open ProtonVPN and it works, but devices
like appletv can’t install vpn apps and I need to route my AppleTV
through a VPN to unlock my Iptv service whenever my ISP decides to be
a jerk
Reply
Hi Jota,
Cheers,
Emmet
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 28 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
So cool being able to be out and about and use the VPN for
security but also be able to connect to my home PLEX server
securely.
Reply
Any way to connect to the VPN from a mobile device like an iPad?
Reply
Hi Joel,
Cheers,
Emmet
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 29 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
However, the author of the script has changed the type of encryption
they are using so your April 2019 update needs another tweak. But that
is not my concern. In the past the key generation step used to take quite
a while (one hourish as I recall) to run. Now it is instantaneous.
Whilst the VPN seems to be working, does anyone know how we can
check it is securely encrypted?
Reply
Hi every one,
I have set-up a VPN Servers using this program, PiVPN and they work
every time.
I nevertheless have an issue with RasPi 3, was working fine for 2 days
and did not show up in the Router as it was alongside the other devices, I
rebooted the Router, the RasPi 3, nothing, so I changed it to RasPi 2 and
it is working like a charm.
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 30 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Reply
Reply
Hey, I’ve done all the configuration by using this guide but I can’t get
connected to the VPN, always reconnecting. Why? Anyone can help me?
Reply
fantastic! thanks
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 31 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Hello, just before I get started on this tutorial I was just wondering if this
process will wipe my raspberry pi? It’s just that I currently have other
software running on it and wanted this to run along side it?
Reply
It won’t wipe your Pi but it may cause issues with other software
running on it. If you wanted to be safe you can always backup your
SD card first so you’re always able to revert back to a safe point.
Reply
Reply
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 32 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Reply
In step 18, you have used the Google DNS server. If they are indeed
known to record data, can you recommend an alternative??
Reply
Hi there,
I have not tried them myself yet but they seem to work, the
OpneDNS is listed on the set-up step, 18, I think.
Cheers
Siamak
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 33 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
You could use the Cloudflare DNS which doesn’t record data. It is
also much faster than any other DNS.
Reply
Reply
Once I am connected to the VPN server which is my pi. How do ftp to the
network where my pi is.
Sorry if this question sounds like a dumb question. But I am not that
good at networking.
Thanks
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 34 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Use your home IP to your FTP, the OpenVPN will redirect the traffic
and your remote appliance will look just like another device in your
home network
Reply
Reply
I get the same error, and the solution was open the port 1194 UDP
in my router (the router connected to my Rasperry pi), and that’s it!,
problem resolved, just was that.
Reply
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 35 of 36
Build Your Own Raspberry Pi VPN Server - Pi My Life Up 1/18/25, 11:55 AM
Page 2 of 2
Previous 1 2
↑ Back to Top
© 2025 Pi My Life Up |
https://pimylifeup.com/raspberry-pi-vpn-server/ Page 36 of 36