This is something I have been using for awhile now, thought i would show you the entire process, This is a tutorial for setting up a Raspberry Pi VPN router.

Requirements for Raspberry Pi VPN Router

Raspberry Pi 3 ►

Private Internet Access ►

Install Raspbian Pixel to your Pi’s sdcard. Use the Raspberry Pi Configuration tool or

sudo raspi-config 


  • Boot to console
  • Configure the right keyboard map and timezone
  • Configure the Memory Split to give 16Mb (the minimum) to the GPU


Static IP Address

/etc/network/interfaces like so:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static

Setup VPN Client

installing openvpn client

sudo apt-get install openvpn

Downloading and uncompressing PIA OpenVPN profiles

unzip -d openvpn

Copy the profile and certificates to OpenVPN Folder

sudo cp openvpn/ca.rsa.2048.crt openvpn/crl.rsa.2048.pem /etc/openvpn/

sudo cp openvpn/US New York.ovpn /etc/openvpn/US.conf

notice that the extension has changed from ovpn to conf create a login file with username and password for PIA

sudo nano /etc/openvpn/login

add your username and password per line



now we need to change the config file to point to correct file locations

sudo nano /etc/openvpn/US.conf

change the following from this:


ca ca.rsa.2048.crt

crl-verif crl.rsa.2048.pem


auth-user-pass /etc/openvpn/login

ca /etc/openvpn/ca.rsa.2048.crt

crl-verif /etc/openvpn/crl.rsa.2048.pem

remember to reboot

Testing the VPN

before moving forward with forwarding traffic, lets test out the connection

sudo openvpn --config /etc/openvpn/US.conf

to Exit use Ctrl + c Enable VPN at boot

sudo systemctl enable openvpn@US

Setup Forwarding and IPTables (routes)

to enable forwarding

sudo nano /etc/sysctl.conf

remove the #

net.ipv4.ip_forward = 1

enable service

sudo sysctl -p

IPTables this is best to just copy and past this to your ssh session. If you want to know more details about these rules, check out the video

sudo iptables -A INPUT -i lo -m comment --comment "loopback" -j ACCEPT
sudo iptables -A OUTPUT -o lo -m comment --comment "loopback" -j ACCEPT
sudo iptables -I INPUT -i eth0 -m comment --comment "In from LAN" -j ACCEPT
sudo iptables -I OUTPUT -o tun+ -m comment --comment "Out to VPN" -j ACCEPT
sudo iptables -A OUTPUT -o eth0 -p udp --dport 1198 -m comment --comment "openvpn" -j ACCEPT
sudo iptables -A OUTPUT -o eth0 -p udp --dport 123 -m comment --comment "ntp" -j ACCEPT
sudo iptables -A OUTPUT -p UDP --dport 67:68 -m comment --comment "dhcp" -j ACCEPT
sudo iptables -A OUTPUT -o eth0 -p udp --dport 53 -m comment --comment "dns" -j ACCEPT
sudo iptables -A FORWARD -i tun+ -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o tun+ -m comment --comment "LAN out to VPN" -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o tun+ -j MASQUERADE

let make sure to keep the rules persistent across reboots

sudo apt-get install iptables-persistent

the installer will ask to save the rules, select YES now if you have new rules you want to add, do

sudo netfilter-persistent save

now lets apply this to startup

sudo systemctl enable netfilter-persistent

ALMOST DONE At this point you can now point your computer gateway to your Raspberry Pi IP address. Now you got a fully functional Raspberry Pi VPN Router. Check  the video for more info   -Don