Table of Contents
  • Home
  • /
  • Blog
  • /
  • Step by Step Procedure to Set Up Open VPN on Raspberry Pi:
November 3, 2023
|
6m

Step by Step Procedure to Set Up Open VPN on Raspberry Pi:


Step By Step Procedure To Set Up Openvpn In Raspberry Pi

Open VPN: The great piece of our remote connectivity puzzle is how to access our Pi when you are out of your home. I thought it was better to share this because its free and easy to set up. If your router provides VPN services on its own, then you might consider that option. If you dont have that option, then an open VPN is a good option you might consider. In this tutorial, we are going to cover Step by step procedures to set up an Open VPN on Raspberry Pi.

Setting up a VPN is not an easy task for those who have no or little knowledge about the networks. Dont worry; there is an easy solution for this. PiVPN. PiVPN is an automated script that allows you to set up an Open VPN in a very easy way. This project, in particular, was started by 0-kaladin and began from the code by StarshipEngineer to help to install OpenVPN on a raspberry pi as simple as it can be.

Prerequisites:

  1. Raspberry Pi device You will need a Raspberry Pi device to install OpenVPN on. The blog post does not specify a particular model, so any Raspberry Pi should work.

  2. Internet connection The Raspberry Pi will need to be connected to the internet in order to download and install the required packages and software. Both wired ethernet and WiFi connections should work.

  3. Updated packages Make sure the Raspberry Pi has the latest OS and package updates installed before beginning the OpenVPN installation. Running sudo apt update and sudo apt upgrade can help with this.

  4. Terminal/command line access You will need to access the terminal/command line on the Raspberry Pi device in order to run the installation commands and configure OpenVPN after install.

  5. Port forwarding enabled To allow external clients to connect to the VPN, port forwarding needs to be configured on the router the Raspberry Pi is connected to. UDP port 1194 needs to be forwarded to the local IP address of the Raspberry Pi.

  6. VPN client software To connect to the OpenVPN server, you will need VPN client software installed on the external devices attempting to connect. The blog post recommends the OpenVPN client software available on their website.

  7. Client configuration file An .ovpn configuration file needs to be exported from the OpenVPN server and imported into the OpenVPN client software in order to connect successfully.

Let me know if you need any clarification or have additional questions!

How to set up Open VPN on Raspberry Pi?

Step 1. Let’s begin the installation by issuing the command on the terminal:

$ curl -L https://install.pivpn.io | bash

Pi starts downloading and installing the required packages from the internet.

Step 2. The script will ask you to answer a few simple questions to set up a VPN. First, it asks to set up the static IP address and hit yes.
Step 3. Set up a user which serves as a service account. Pi user is just fine to continue this.
Step 4. Choose a user for Pi
Step 5. Next is a very important decision to make. PiVPN initially supported OpenVPN. Now, it started supporting WireGuard, another VPN solution, which is started gaining popularity, but it isn’t close to the universe and support as much as Open VPN. We are choosing OpenVPN for this demonstration.
Step 6. The script will take a couple of minutes to download and install the packages.
Step 7. In the next step, it asks to set up the port and protocol information. It is just fine to go with the default, which is UDP with 1194.
Step 8. Next, it asks you to select the DNS Provider of your choice. We are selecting CloudFlare to demonstrate.
Step 9. Just take the default No here in Custom Search Domain.
Step 10. Supply the DNS name
Step 11. Accept the few default options and let the script generate the server and hash-based message authentication code or HMAC.
Step 12. Select the ECDSA certificate size
Step 13. In the end, it suggests enabling the auto upgrades to fetch security updates. We let this option for you to decide.
Step 14. Select ‘Yes’ if you want to download the upgrades the security patches
Step 15. If you had selected yes to unattended-upgrades. It downloads a few more things. And, that’s it. You are going to see an installation complete message on your window. Your Open VPN is installed and almost ready to use. The only thing left is to reboot and add VPN clients.
Step 16. After rebooting the Pi, open the terminal and type pivpn, a new command which allows adding new clients. See the comprehensive list of options for this new command.
Step 17. Pass the -a or add parameters to the pivpn command to add a new client. And enter the new client name and password for it.
Step 18. Set the password for the client
Step 19. Once done, a new file Mel.ovpn will be created under the /home/pi/ovpns/ which needs to be imported to the client.
Step 20. You should need to setup the port forwarding on your internet router as well. As we don’t know what router you have, we kept this out of the topic and let you configure this on your router. We suggest you to check your router’s user manual to know about port forwarding on your router.

Once you find the port forwarding options on your router, enable it and create a new port forwarding rule. Enter this information in the rule. Service port and internal port should be 1194, fill Pis IP in the IP address, Protocol should be UDP, and thats all; save these settings to your new rule.

Step 21. Download the client application for your operating system from the Open VPN site and Install it on the client machine.
Step 22. Open the client application go to import files, and browse the ovpn file to import. It may ask to enter the password. Enter the password you entered in the previous step. After a successful connection with the VPN server. You are going to see a new IP address from the VPN server.

This completes the procedure. Thats all.

Thank you for reading this article. Please visit the below links to read more such interesting articles. Peace leave your comments here below and let us know your feedback. This helps us to bring more such articles.

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

Recently added

Cloud & OS Platforms

View All

Learn More About Cyber Security Security & Technology

“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”

Cybersecurity All-in-One For Dummies - 1st Edition

"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.

Tools

Featured

View All

Learn Something New with Free Email subscription

Subscribe

Subscribe