Creating your own VPN on a Raspberry Pi is a relatively straightforward process, involving numerous steps. We've put together a short guide that'll walk you through installing an OS, setting up the VPN, creating users, and logging in using your favorite client.
Products used in this guide
- The Pi itself: Raspberry Pi 4 ($66 at Amazon)
- MicroSD card: Samsung EVO 32GB MicroSD ($14 at Amazon)
How to build your own VPN with Raspberry Pi
Configuring your own VPN is a great way to save a little on a monthly subscription while getting to know the ins and outs of how it all works by setting it all up. This route does come with some risks, however. Since this server will be running on your home network and will be accessible from outside, you'll need to make sure everything on your LAN is secure.
Installing the Raspbian OS
- Download Raspbian OS ISO.
- Write the ISO file to your SD card, using an app like Rufus.
- Insert the SD card into the Raspberry Pi.
- Plug in your favorite keyboard and mouse.
- Follow the installation wizard.
- Upon completion, ensure the OS is secured with a password.
- We'll also need to set a static IP for the VPN server to use. Edit
/etc/dhcpcd.confand set static ip_address to one not used by any other device on the network. Here's an example of what may be present:
- interface eth0
- static ip_address=192.168.1.30/24
- static routers=192.168.1.1
- static domain_name_servers=192.168.1.1
- Save the file.
- If you have a static external IP from your ISP you can move onto installing the VPN, but if your ISP provides a dynamic IP address (as in it changes every now and then to a new value), follow this excellent guide on PiMyLifeUp on setting up DNS on Raspbian OS.
Installing a VPN
Install PiVPN by pasting the following command into the terminal (and hit enter):
curl -L https://install.pivpn.io | bash
- Run pivpn by typing it into the terminal.
- Follow the wizard.
- Hit Yes on the static IP address confirmation screen.
- Hit OK.
- Hit OK.
- Choose your user, hit OK.
- Hit OK.
Choose Yes to enable automatic upgrades. (Highly recommended.)
- Choose UDP and hit OK.
- Enter a random port number not already used by another network service and hit OK. (We recommend setting a custom port to better enhance security against potential scans and attacks.)
Confirm your port number by hitting Yes.
- Choose 2048-bit encryption and hit OK. (You can use 4096, but this would affect VPN performance.)
- Hit OK and wait a while for various VPN-related things to be installed and configured.
- Hit Yes when the installer asks you to use OpenVPN 2.4 if you know your favorite client supports it.
- Choose DNS Entry and hit OK. (Leave on public IP if you have a static IP address and did not set up DNS for external access.)
- Enter the custom DNS name for the VPN server.
- Choose a DNS provider.
- Hit Yes to reboot the Raspberry Pi.
Adding a user to the VPN
- Run the following in the terminal:
sudo pivpn add
- Enter an identifying name for the user.
- Set a secure password.
- Now you need to copy the .opvn files stored in /home/pi/ovpns to devices you wish to connect to the VPN. You can think of these as certificates. Use a USB to take them off the Pi or connect to the device using an SFTP client like FileZilla.
- Provided with the password and .opvn file, users will now be able to connect to the VPN.
Connecting to the VPN
- Download the OpenVPN client, or you can use your favorite alternative.
- Set up a new connection by importing the .opvn file and entering the user password.
- Connect, and you're now good to go!
The Raspberry Pi 4 is the latest iteration of the small computer from Raspberry, offering considerable computing performance for such a small package.
Samsung's EVO MicroSD range is excellent. The 32GB card is perfect for installing Raspbian OS, any apps we need on the device, and more.
We test and review VPN services in the context of legal recreational uses. For example:
1. Accessing a service from another country (subject to the terms and conditions of that service).
2. Protecting your online security and strengthening your online privacy when abroad.
We do not support or condone the illegal or malicious use of VPN services. Consuming pirated content that is paid-for is neither endorsed nor approved by Future Publishing.
We may earn a commission for purchases using our links. Learn more.
Best Affordable Desk Chair for Kids in 2020
Everyone needs a comfortable and practical chair to sit at their desk with, and that includes kids who are working on homework or arts-and-crafts. Here's a list of some of our favorite options.
Should your next computer be a mini PC? These are your best options.
Windows PCs come in all shapes and sizes, and whatever your needs there's a computer out there to suit you. Here are the best to choose from if you're looking for a new mini PC.
Best Affordable Desk for Kids in 2020
Desks are incredibly useful surfaces that help adults stay on top of work, but they're great for kids, too! Here's a list of some of our favorite affordable kid-friendly desks on the market.