Raspberry Pi is a marvel of technological advancement, as it proves that strength isn’t all about size. The Raspberry Pi is actually a single-board computer.
- Raspberry Pi devices can be used for a lot of purposes, but one of the most popular ones is hosting private VPN servers.Although it’s not exactly easy to configure a VPN server on your RPi device, it’s not rocket science, either.Check out our VPN section for more news, guides, and reviews on VPNs.Visit the How-To Hub to discover more VPN guides for common and uncommon issues.
Much like your phone, it can fit in your pocket (although it might look a bit bulgy) and, if you have the peripherals, can help you interface with it anywhere.
However, thanks to its size-based convenience, many choose to use these devices for very specific roles.
Some turn them into vintage arcades using emulators, while others use them as email servers, tiny media centers, or even VPN servers.
How to set up a VPN with Raspberry Pi?
Conclusion
All things considered, it seems that the RPi is indeed a multi-talent tool that can also be used as your private, personal VPN server.
Browse the web from multiple devices with increased security protocols.
Access content across the globe at the highest speed rate.
Connect to thousands of servers for persistent seamless browsing.
Requirements
- Raspberry Pi (we used an RPi 2 model B)
- A microSD card (for storage purposes)
- An operating system (we used Rasperry Pi OS, formerly Raspbian)
- Ethernet cable (using Wi-Fi is a bit more complicated)
- USB cable (to power up the RPi)
- A power source (we plugged our RPi into our router)
- Peripherals (keyboard + mouse)
- An HDMI cable
- Display (monitor, TV)
- An SSH client (we used Solar Putty)
Note that you won’t need all of these components to install the VPN on the Raspberry Pi. If you connect the device to a working Internet source, you can access it via SSH.
However, note that this method can have some drawbacks, as it involves having to reconnect to the RPi once you change network settings. We’ll get to that in just a bit.
Assuming that you have all the required components ready, let’s proceed with setting up the VPN on your RPi.
Connecting to your Raspberry Pi
- Plug the Ethernet cable into your router and Raspberry Pi
- Connect your RPi to a power source (we used our router)
- Install an SSH client on your computer
- Access your router’s gateway in your browser
- Locate and save the RPi’s local IP address
- Run the SSH client on your PC
- Create a new SSH session within the client
- Type the IP address you noted down earlier (or use raspberry/raspberry.local as the address)
- Use pi as username and raspberry as password
- Launch the session
Make sure everything is up-to-date
Before you proceed, you must understand that Raspberry Pi OS is more sensitive to change than, for instance, Windows.
Therefore, it won’t offer to fix any compatibility issues automatically.
Instead, you have to make sure that the environment is fit before installing anything, including VPN software on your Raspberry Pi.
Fortunately, doing so isn’t difficult with proper guidance.
Follow these steps:
- With the session active, type sudo apt-get update in the SSH terminal
- Wait for the update process to finish
- Type sudo apt-get upgrade in the same terminal as before
- If prompted, type Y for confirmation and hit Enter on your keyboard
- Wait for the upgrade process to complete
Performing these two operations is of utmost importance, as running a VPN server implies a certain degree of security.
Keeping everything up-to-date on your Raspberry Pi device is a surefire method to avoid compatibility issues and exploitable vulnerabilities.
Note that these procedures can take quite a while, especially the upgrading part one. So, in the meantime…
Get a static IP address
Having a static IP address is quite important in this case. It will allow you to access your personal Raspberry Pi VPN server from virtually anywhere in the world without worrying that its IP will change at some point.
If you already have a static IP address, you should be fine.
Some ISPs offer this type of service by default, although many prefer the dynamic approach to solve (or better yet delay) the IP address pool exhaustion.
However, if you have a dynamic (that changes periodically) IP address, you can use DHCP or a free dynamic DNS service.
The DHCP method is a bit more complicated and depends on several factors such as router and ISP.
Thus, we suggest you pick a dynamic DNS service, but not before checking if your router has DDNS (dynamic DNS) support.
Installing PiVPN on Raspberry Pi
- In the SSH terminal, type curl -L https://install.pivpn.io | bash
- Wait for the package configuration to unfold (automated)
- Confirm the turning of your Raspberry Pi into a VPN server
- Acknowledge the DHCP settings
- Choose Yes or No depending on your DHCP/manual static IP configuration situation
- Select a user (pi by default)
- Wait for the PiVPN installation to unfold for a while
- Select OpenVPN from the VPN menu by using the Space key on your keyboard
- Confirm by pressing Enter
- Choose No when prompted to customize settings (default settings are good enough)
- Leave the default port open (1194)
- Choose the DNS provider of your VPN clients
- Select DNS if you don’t have a static IP address
- Define the DNS name of the server if applicable
- Make sure to enable unattended-upgrades
- Reboot the system, as recommended
That’s it, you’ve successfully installed PiVPN on your Raspberry Pi device. It’s not exactly rocket science but has a lot of steps, which can easily confuse novice users.
Create VPN profile
- Launch the SSH session once more
- In the terminal, type pivpn add
- Type a name for your client
- Define how many days until the certificate expires
- Type and confirm the password
After performing all the steps above, your VPN profile should be automatically created and you should now be able to use it without any issues.
Note that the profiles are saved on the RPi’s storage unit, so you’ll have to fetch them from there (you can use remote VNC or a card reader).
Note that you’ll also need to forward the port you used earlier. In our case, it was port 1194, so we forwarded this one.
Connect to your private RPi VPN
- Download OpenVPN Connect for Windows
- Install it on your PC
- Launch the OpenVPN Connect app
- Go to the File tab
- Browse to the OVPN file you got from your RPi
- Import it within the app
- Configure a profile name for it
- Click the Add button
- Flip the switch to activate the VPN connection
- Type the private key you used to create the profile
You should be now connected to the VPN server you personally configured on your RPi. The OpenVPN Connect client will show you some useful information such as your sent and received traffic, connection duration, and the time you received the last packet.
If for some reason you can’t connect to your VPN, check if you forwarded the port correctly (make sure to use the local IP address of your RPi instead of its external one).
Should you still be having difficulties, try the following:
- Reinstall PiVPN
- Make it use the public IP address (even if not static)
- Create the OVPN file
- Open the OVPN file in a text editor
- Replace the public IP with your DDNS manually
That’s it. The VPN connection should now work like a charm.
You can also connect to the VPN server with your phone. However, note that for every new client that connects to your server, you need to create a new VPN profile.
For better security, make sure that each profile has a different, strong password.
Your connection is not secure - websites you visit can find out your details:
- Your IP Address:loading
Companies can sell this information, alongside your location and internet provider name, and profit from it by serving targeted ads or monitoring your data usage.
We recommend Private Internet Access, a VPN with a no-log policy, open source code, ad blocking and much more; now 79% off.
- raspberry piVPN
Email *
Commenting as . Not you?
Comment