How to Install PiVPN for Easy VPN Setup on Ubuntu

Setting up a VPN (Virtual Private Network) used to sound scary to me. It seemed like something only computer experts could do. But then I found PiVPN. It’s a small tool that makes setting up your own VPN really easy—especially on Ubuntu, which is a popular version of Linux.

In this post, I’ll walk you through how to install PiVPN step by step. I’ll explain what a VPN is, why it’s useful, and how I got it working on my own computer at home. If I can do it, you can too.

Let’s dig in. (Get it? Like a piñata VPN? No? Okay, I’ll stop.)


What Is a VPN, and Why Bother?

A VPN (Virtual Private Network) is a secure connection between your computer and the internet. It helps you browse safely and keep your data private. Instead of sending your internet traffic directly, a VPN puts your data into a secure “tunnel” first.

Here’s why I like using a VPN:

  • It hides my real location.
  • It protects my data when I use public Wi-Fi (like at coffee shops).
  • I can access files on my home network when I’m not home.

If you’ve ever used public Wi-Fi and worried about someone snooping, a VPN is like an invisibility cloak for your internet.

Now, PiVPN is a script—that’s just a short piece of code—that helps you install a VPN quickly. It supports two VPN types: WireGuard and OpenVPN. Don’t worry, I’ll explain those too.


WireGuard vs OpenVPN (Like Coke vs Pepsi)

WireGuard and OpenVPN are both VPN technologies. Think of them like two brands of the same tool. They do the same job—just in slightly different ways.

WireGuard is newer, faster, and uses simpler code. It’s like the cool new bike on the block.

OpenVPN is older, more tested, and works on more devices. It’s like the reliable old car that’s been through a lot but still runs great.

For my setup, I chose WireGuard because it’s easier and works faster for what I need. But you can choose either one during setup.


Before You Start

You’ll need just a few things:

  • An Ubuntu machine (a laptop, desktop, or even a Raspberry Pi will work)
  • A user account with sudo access (sudo lets you do “admin” stuff)
  • A basic internet connection

I used a small Ubuntu server at home. You can do this on a cloud server too, but I like knowing my VPN is in my house, guarding my network like a tiny digital ninja.


Step-by-Step: Installing PiVPN on Ubuntu

Here comes the fun part. Installing PiVPN takes only a few minutes.

1. Update Your System

First, make sure everything is up to date. Open the terminal and type:

sudo apt update && sudo apt upgrade -y

This makes sure your Ubuntu machine is running the latest software. I always do this before installing anything new.

2. Install PiVPN

Now install PiVPN by running this:

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

This command downloads the PiVPN installer and runs it.

Don’t worry if the screen fills with a lot of text. Just read carefully and follow the prompts.

3. Choose Your VPN Type

PiVPN will ask you which VPN you want: WireGuard or OpenVPN.

Pick one based on your needs. I went with WireGuard because it’s quicker to set up and uses fewer resources.

Use the arrow keys and press Enter to select.

4. Select Network Interface

Next, it will ask which network card to use. Most of the time, the default option is correct. Just press Enter to continue.

5. Set a Static IP

Your VPN server needs a fixed IP address so your devices can find it. PiVPN can help set this up.

Choose “Yes” when asked if you want to set a static IP. It’ll show you the current IP and offer to make it permanent.

I accepted the suggested address, and it worked just fine.

6. Configure Port

You’ll now pick a port number. A port is like a door into your computer. The default (51820 for WireGuard or 1194 for OpenVPN) is usually fine.

I kept the default. But if your internet provider blocks it, you can pick a different one.

7. Enable Unattended Upgrades (Optional)

You’ll get the option to enable automatic updates for security. I said yes—it’s safer that way, and I don’t have to remember to do it later.

8. Reboot and Test

Once setup finishes, reboot your system:

sudo reboot

After it restarts, you’re ready to add VPN users.


Add a VPN User (Client)

After the reboot, log in again and type:

pivpn add

This creates a new VPN profile. You’ll be asked for a name. I used “myphone” for my smartphone.

Once done, it saves a file in your home folder. You’ll need this file to connect your device to your VPN.


Connect Your Device

Now you’ll move the configuration file to your device. You can do this with email, USB, or a cloud folder—whatever’s easiest.

If you’re using WireGuard:

  1. Download the WireGuard app on your phone.
  2. Open it and tap Import from file.
  3. Choose the config file you copied.

That’s it. Your phone is now a stealthy VPN ninja.


Quick Benefits of PiVPN

Just to review what you’ve gained:

  • Privacy: Your data is protected, even on sketchy Wi-Fi.
  • Access Anywhere: Reach your home network from anywhere.
  • Low Cost: It’s free, except the cost of your own device.

I even set this up on a Raspberry Pi and tucked it behind my TV. It just runs silently in the background.


Troubleshooting Tips

Got stuck? Try these tricks:

  • Make sure your router has port forwarding set up for your VPN port.
  • Check your firewall settings (on Ubuntu and your router).
  • Use pivpn -d to run a debug tool if something isn’t working.
  • Try restarting everything—seriously, it works more than you think.

Handy PiVPN Commands

Here are some simple commands I use often:

  • pivpn add – Add a new VPN user
  • pivpn list – See connected users
  • pivpn revoke – Remove a user
  • pivpn -d – Run a quick diagnostic test

I like keeping these in a sticky note near my monitor, just in case.


A Few Lessons I Learned

Here’s what I wish someone told me earlier:

  • Don’t skip setting a static IP. If your server’s IP changes, your VPN won’t work.
  • Keep a copy of your config files. You’ll thank yourself when you get a new phone or reset it.
  • Test it on Wi-Fi first before using mobile data. It’s easier to debug that way.

Final Thoughts

Setting up PiVPN was way easier than I thought. It felt like installing a helpful guard dog that never barks or bites—just silently keeps watch.

Now when I’m using hotel Wi-Fi or borrowing a friend’s network, I know my data is wrapped in a warm blanket of encryption.

I even showed my cousin how to do it, and he calls it “VPN-easy” now. (Get it? Like peasy?)

So, are you ready to make your internet life safer and smarter? Why not give PiVPN a shot? You’ve got nothing to lose—except your IP address visibility.

 

 

Leave a Reply