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.
The best motherboards for an AMD Ryzen 5 2600 CPU
There's a wide range of AM4 motherboards available for your AMD Ryzen 5 2600, so I've rounded up a few of my favorites.
Best Minecraft Fan-made Art, T-Shirts, Stickers, Posters, and more!
Minecraft has become a global phenomenon over the years, and its fans have created tons of awesome different Minecraft-themed accessories and apparel for others to enjoy. Here are some of our favorites!
Jazz up your XPS 15 with these great accessories
There are so many accessories that can help to enhance your Dell XPS 15 experience that you’d be remiss if you didn’t consider some of them. Here are a few of our favorites.