Home Blog About
3 min read

Raspberry Pi VPN Gateway: Route All Home Devices

Set up a Raspberry Pi VPN gateway to route smart TVs, gaming consoles and IoT devices through a VPN. Step-by-step OpenVPN setup guide included.

NetworkingCybersecurityraspberry pivpnnetworkingprivacytutorial

Your laptop can run a VPN. Your phone can too. But what about your smart TV? Your gaming console? That IoT device that definitely phones home to servers you’ve never heard of?

That’s where a VPN gateway comes in. And a Raspberry Pi is the perfect device to build one.

💡 Why I Built This

I’d been meaning to set up a router-wide VPN for ages. The final push? Buying a Samsung QLED TV.

I don’t trust TizenOS (Samsung’s smart TV operating system) with my data. Plus, routing through a VPN lets me access streaming services that aren’t available in Australia.

💡 VPN-capable routers exist but they’re expensive. A Raspberry Pi does the same job for a fraction of the cost.

🛠️ What You’ll Need

  • Raspberry Pi (any model works; I recommend Ubuntu Server)
  • VPN subscription (I use ProtonVPN — read their threat model)
  • OpenVPN config files from your VPN provider

⚙️ Step-by-Step Setup

1. Install OpenVPN

$ sudo apt install openvpn

2. Get Your VPN Config Files

Navigate to the OpenVPN directory:

$ cd /etc/openvpn

Download config files from your VPN provider. For ProtonVPN, grab them from account.protonvpn.com/downloads and unzip.

3. Set Up Authentication

Create an auth file with your VPN credentials:

$ sudo nano /etc/openvpn/auth.txt

Add your username on line 1 and password on line 2. ProtonVPN has personal access tokens you can use instead of your main account credentials.

⚠️ Security note: Storing credentials in plain text isn’t ideal. Consider file permissions (chmod 600) at minimum.

4. Configure OpenVPN to Use Your Auth File

Edit your chosen config file and add this line after client:

auth-user-pass /etc/openvpn/auth.txt

5. Create a Startup Script

Create /etc/openvpn/vpn.sh:

#!/bin/bash
sudo killall openvpn
sudo -b openvpn /etc/openvpn/{your-config-file}.ovpn

Make it executable:

$ chmod +x /etc/openvpn/vpn.sh

6. Start the VPN

$ sudo bash /etc/openvpn/vpn.sh

Test with a ping:

$ ping 1.1.1.1

✅ Verifying It Works

SSH into your Raspberry Pi and check:

ubuntu@ubuntu:~$ nmcli connection show
NAME         UUID                                  TYPE      DEVICE
tun0         e5a1xbde-ab39-4c5c-886x-8f316d5xx217  tun       tun0

ubuntu@ubuntu:~$ netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
103.107.xxx.100 10.1.x.x        255.255.255.255 UGH       0 0          0 eth0

$ curl ifconfig.me
103.107.xxx.123

That exit IP (103.107.xxx.123) is a server in Singapore, not my real location.

💻 My Setup

🔗 Connecting Other Devices

On your device (in my case, the Samsung TV), manually configure the network settings:

  1. 🔧 Set the gateway IP to your Raspberry Pi’s local IP (not your router’s IP)
  2. 🔧 Assign a new IP address to your device
  3. 📖 Check your router’s manual for specifics

Now all traffic from that device routes through the VPN. My TV thinks it’s in Singapore, and I can access streaming services directly through the built-in apps.

🏁 The Takeaway

For the cost of a Raspberry Pi and a VPN subscription, you get:

  • 🔒 Privacy from your ISP and smart device manufacturers
  • 🌐 Access to geo-restricted content
  • ⚙️ Control over which devices use the VPN

Related guides:

Worth the afternoon of tinkering. 🔐

Share: