Using a commercial VPN is convenient, but you have to trust they don’t sell your data. The alternative is setting up your own VPN server at home, where you control everything. In this guide, I’ll show you how to set up your own VPN server at home, step by step, even if you’ve never touched a server before.
Table of contents
Table of contents
Why setting up your own VPN makes sense
Commercial VPNs (NordVPN, ExpressVPN, etc.) solve two problems: privacy and geographic access. But they have downsides few people mention:
- Trust: You trust the VPN doesn’t log your activity. Some have done so.
- Speed: Your traffic goes through servers shared with thousands of users.
- Cost: Between $3 and $12 per month for life.
- Blocks: Many services detect and block commercial VPN IPs.
A personal VPN solves these problems:
- You’re the only user, so no data theft risk
- Speed depends only on your internet connection
- Cost is zero after initial setup
- Your home IP is rarely blocked
The downside is you can’t easily change countries. Your VPN always shows your real location (your home). If you need content from other countries, you’ll need a commercial VPN.
Pro-tip: A personal VPN is ideal for connecting to your home network from outside: accessing files, viewing your security camera, or using your NAS. It’s not ideal for bypassing geographic blocks.
What you need to get started
Before setting up, make sure you have the basics:
Hardware:
- A computer always on (Raspberry Pi is ideal for low power consumption)
- Or a VPN-compatible router (some ASUS and Netgear routers support it)
- Or a NAS (Synology and QNAP include VPN server)
Software:
- Linux operating system (Raspberry Pi OS, Ubuntu Server, or Debian)
- OpenVPN or WireGuard (the two most popular protocols)
Network:
- An internet connection with public IP (ask your ISP)
- Access to your router’s configuration to open ports
- Dynamic DNS if you don’t have a static IP (using No-IP or DuckDNS)
Raspberry Pi minimum requirements:
- Raspberry Pi 4 or higher (2GB RAM minimum)
- 16GB+ microSD card
- Ethernet cable (WiFi works but less stable)
- USB-C power supply
In my case, I use a Raspberry Pi 4 with 4GB RAM that cost about $60. It’s been running 24/7 consuming only 5W, which is about $4/year in electricity.
Setting up WireGuard on Raspberry Pi
WireGuard is more modern and faster than OpenVPN. It’s my recommendation for a personal VPN:
Step 1: Install WireGuard
- Connect to your Raspberry Pi via SSH or terminal.
- Update the system:
sudo apt update && sudo apt upgrade -y - Install WireGuard:
sudo apt install wireguard -y
Step 2: Generate keys
- Generate private key:
wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey - Note down both keys (private and public).
Step 3: Configure the interface
- Create the config file:
sudo nano /etc/wireguard/wg0.conf - Enter this configuration:
[Interface]
PrivateKey = <your_private_key>
Address = 10.0.0.1/24
ListenPort = 51820
SaveConfig = true
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
Step 4: Open port on router
- Access your router’s configuration (usually 192.168.1.1).
- Find “Port Forwarding”.
- Open port 51820 UDP to your Raspberry Pi’s IP.
Step 5: Enable WireGuard
- Run:
sudo systemctl enable wg-quick@wg0 - Start the service:
sudo systemctl start wg-quick@wg0 - Verify it works:
sudo wg show
Connecting your phone and laptop to the VPN
Once the server is running, you need to configure the clients:
On Android:
- Download the WireGuard app from Google Play.
- Open the app and tap ”+” > “Create from file” or “Create yourself”.
- Configure:
[Interface]
PrivateKey = <client_private_key>
Address = 10.0.0.2/24
DNS = 1.1.1.1
[Peer]
PublicKey = <server_public_key>
Endpoint = <your_public_ip>:51820
AllowedIPs = 0.0.0.0/0
- Save and activate the tunnel.
On Windows:
- Download WireGuard from wireguard.com.
- Import the configuration or create it manually.
- Activate the tunnel.
On iPhone:
- Download the WireGuard app from App Store.
- Import the configuration or create it manually.
To automatically generate configurations, use PiVPN:
- Run:
curl -L https://install.pivpn.io | bash - Follow the interactive wizard.
- Generate clients with:
pivpn add
| System | Recommended App | Configuration |
|---|---|---|
| Android | WireGuard | Manual or PiVPN |
| iOS | WireGuard | Manual or PiVPN |
| Windows | WireGuard | Manual or PiVPN |
| macOS | WireGuard | Manual or PiVPN |
| Linux | WireGuard CLI | Terminal |
Setting up Dynamic DNS for remote access
If you don’t have a static IP at home (most ISPs don’t provide one), you need dynamic DNS:
DuckDNS (free):
- Register at duckdns.org.
- Create a subdomain: mypi.duckdns.org.
- Install the client on your Raspberry Pi:
sudo apt install cron -ycrontab -e- Add:
*/5 * * * * curl -s "https://www.duckdns.org/update?domains=mypi&token=<your_token>"
- Update WireGuard config to use mypi.duckdns.org instead of IP.
No-IP (free with limitations):
- Register at noip.com.
- Create a hostname.
- Install the DUC client on your Raspberry Pi.
With dynamic DNS, when your IP changes, the domain updates automatically. You can always connect to mypi.duckdns.org regardless of the current IP.
Pro-tip: Use DuckDNS instead of No-IP. It’s completely free, doesn’t require renewal every 30 days, and works perfectly with WireGuard.
Alternatives to a personal VPN based on your use case
Not everyone needs to set up a full VPN server. Depending on what you’re looking for, there may be simpler options:
Remote access to your NAS files
If your main goal is accessing your files from outside home, you don’t need a full VPN. Synology and QNAP offer integrated remote access services (QuickConnect, myQNAPcloud) that work without opening ports or configuring dynamic DNS. It’s less secure than a VPN, but much easier to set up.
Access to your desktop computer
Apps like TeamViewer, AnyDesk, or Chrome Remote Desktop let you control your PC from anywhere without needing a VPN. They’re ideal if you only need to access one specific computer.
Security camera access
Many modern cameras (Ring, Nest, Reolink) have their own apps with cloud access. You don’t need a VPN to view your cameras. However, if you prefer not to rely on the manufacturer’s cloud, a personal VPN is the most private solution.
Solution comparison
| Solution | Difficulty | Security | Cost | Best for |
|---|---|---|---|---|
| Personal VPN (WireGuard) | High | Very high | Almost zero | Full home network access |
| QuickConnect (Synology) | Low | Medium | Free | NAS file access |
| TeamViewer / AnyDesk | Very low | Medium | Free/personal | Remote PC control |
| Commercial VPN | Very low | Variable | $3-12/month | Location switching |
My recommendation: If you only want to access files or view cameras, try the alternatives first. If you need full access to your home network with maximum security, that’s when setting up a personal VPN is worth it.
FAQ
Is it legal to have your own VPN server?
Yes, completely legal. It’s your network and your connection. There’s no restriction on creating a VPN server in your own home.
Does a personal VPN reduce my internet speed?
Slightly. Your VPN speed depends on your upload connection, which is usually lower than download. With a 600/100 Mbps fiber connection, your VPN will reach 100 Mbps upload.
Can I use my personal VPN to bypass geographic blocks?
No. Your VPN will show your home IP, which is from your country. For content from other countries, you need a commercial VPN with international servers.
What happens if my Raspberry Pi shuts down?
Your VPN stops working until you turn it back on. Use a UPS to avoid power outage issues. The Raspberry Pi consumes so little power that a cheap UPS gives it hours of autonomy.
Conclusion
Setting up your own VPN server at home is simpler than it sounds, especially with WireGuard and a Raspberry Pi. You’ll have a secure connection to your home network from anywhere, without relying on paid services or trusting your data to third parties. Spend an afternoon setting it up and you’ll have your own VPN running forever.
TecnoOrange