• Home
  • |
  • Blog
  • |
  • 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’s better to share this because it’s free and easy to setup. If your router provides VPN services on its own than you might consider that option. If you don’t have that option, then open VPN is a good option you might consider. In this tutorial, we are going to cover Step by step procedure 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. Don’t worry, there is an easy solution for this. PiVPN. PiVPN is an automate script that allows you to setup 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.

Time needed: 10 minutes.

How to set up Open VPN on Raspberry Pi?

  1. Let’s began the installation by issuing the commend on the terminal:

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

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

  2. The script will ask you to answer few simple questions to setup VPN. First it asks to setup the static IP address and hit yes.

    setup the static IP address in Raspberry Pi

  3. Setup a user which serves as a service account. Pi user is just fine to continue this.

    setup VPN user on Raspberry Pi

  4. setup VPN user on Raspberry Pi (2)

  5. Next is very important decision to make.  PiVPN initially supported OpenVPN. Now, it started supporting WireGuard, an another VPN solution, which is started gaining popularity but it isn’t close to the universe and supported as much as Open VPN. We are choosing OpenVPN for this demonstration.

    Chose OpenVPN

  6. The script will take a couple of minutes to download and install the packages.

    OpenVPN installation is in progress

  7. In next step it asks to setup the port and protocol information.  It just fine to go with the default which is UDP with 1194.

    configure OpenVPN custome port

  8. Next it asks to select the DNS Provider of your choice.  We are selecting CloudFlare to demonstrate.

    set up DNS setting in OpenVPN in raspberry pi

  9. Just take the default No here in Custom Search Domain.

    custome search domain in OpenVPN

  10. custome search domain in OpenVPN (2)

  11. Accept the few default options and let the script generate the server and hash-based message authentication code or HMAC.

    OpenVPN installation modes

  12. ECDSA certificate key size set up wizard

  13. At the end, it suggests to enable the auto upgrades to fetch security updates. We let this option for you to decide.

    auto upgrade OpenVPN in raspberry pi

  14. auto upgrade OpenVPN in raspberry pi (2)

  15. If you had selected yes to unattended upgrades. It downloads few things more. And, that’s it. You are going to see a installation complete message on your window. Your Open VPN is installed and almost ready to use. Only thing left is to reboot and add VPN clients.

    OpenVPN installation complete

  16. After rebooting the Pi, open the terminal and type pivpn, a new command which allows to add new clients. See the comprehensive list of options of this new command.

    pivpn cmd list

  17. Pass the  -a or add parameters to the pivpn command to add new client. and enter the new client name and password for it.

    Adding a new client in pivpn

  18. Adding a new client in pivpn (2)

  19. Once done, a new file Mel.ovpn will be created under the /home/pi/ovpns/ which needs to be imported at the client.

    import pivon settings to client

  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 to 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 and create a new port forwarding rule. Enter these information in the rule. Service port and internal port should be 1194, fill Pi’s IP  in the IP address, Protocol should be UDP, and that’s all, save this settings to your new rule.Enabling port forwarding in the router router

  21. Download the client application for your operating system from the Open VPN site and Install it on the client machine.

  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 successful connection with the VPN server. You are going to see a new IP address from VPN server.

This completes the procedure. That’s 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.

About the author

Arun KL

To know more about me. Follow me on LinkedIn Hi All, I am Arun KL, an IT Security Professional. Founder of “thesecmaster.com”. Enthusiast, Security Blogger, Technical Writer, Editor, Author at TheSecMaster. To know more about me. Follow me on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn Something New with Free Email subscription

Email is also one of the ways to be in touch with us. Our free subscription plan offers you to receive post updates straight to your inbox.