
Make your own private VPN server!

Download the the file here:
​
Raspberry Pi VPN, QuickStart for fixed Static IP
A. Allow access to your RPi from the internet
-
Physically connect the RPi to the router in the country you want to access. You may want to turn off WiFi.
-
Enable VNC on the RPi for remote access (sudo raspi-config). Consider changing the RPi’s password.
-
You may want to ‘sudo apt-get update’ and ‘sudo apt-get upgrade’
-
On the router, figure out the RPi’s DHCP IP number. Make it static, so it never changes even with power cycles.
-
On the router, open 2 ports, 5900 for VNC and we’ll use 55798 for VPN.
-
From the RPi (or other device connected to the same router), record its IP number (Google ‘what is my IP number’)
B. Setup the VPN server on the RPi
-
‘curl -L https://install.pivpn.io | bash’
-
Don’t allow automated updates - seems to be a pivpn bug
-
Enter 55798 for the port, step A5
-
Choose ‘pi’ as the user
-
Enter the DHCP IP number, step A4
-
Enter the router’s IP number (Public IP), step A6
-
Choose ‘Google DNS’
-
This process will take more than 10 minutes to generate the encryption.
C. Create a VPN profile
-
‘pivpn add nopass’, this means no password is needed
-
Enter a profile name
-
Copy the XXX.opvn file to the phone or computer you want to use. web.wechat.com is a easy way.
D. Download OpenVPN on the target computer or phone. Load the profile from step C.
​
-
Allow access to your RPi from the internet:
-
Connect the RPi to the router where you want access. Maybe in your home country.
-
On the router, record your current IP address and DNS server address
-
Reserve the RPi’s DHCP IP address, so it doesn’t change (usually 192.168...)
-
Use port forwarding to point to that IP address (any port number will do – remember it)
-
Setup a Dynamic IP domain because the IP number your ISP gives you may change:
-
Go to noip.com and setup an account. You will need to activate it by email.
-
Remember the new domain name, your account user name, and your noip.com password
-
Set it to the current IP address that you recorded in step A2
-
Setup the Dynamic DNS client on the RPi:
-
‘sudo apt-get update’
-
‘sudo apt-get upgrade’ # makes sure you are on the latest Raspbian version
-
‘sudo apt-get install ddclient libjson-any-perl’
-
just skip through the install questions, we’ll be overwriting them later
-
-
Copy the file ‘ddclient-3.8.3.tar’ to the Raspberry Pi
-
‘tar -xvf ddclient-3.8.3.tar’
-
‘sudo cp -f ddclient-3.8.3/ddclient /usr/sbin/ddclient’
-
‘sudo mkdir /etc/ddclient’
-
‘sudo mv /etc/ddclient.conf /etc/ddclient’
-
‘sudo nano /etc/ddclient/ddclient.conf’
-
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
-
ssl=yes
-
protocol=dyndns2
-
server=dynupdate.no-ip.com
-
login=your_username [from B2]
-
password=your_password [from B2]
-
your.domain.com [from B2]
-
-
‘sudo /etc/init.d/ddclient restart’
-
Look for an IP address update every week:
-
‘sudo nano /etc/default/ddclient’
-
run_daemon="true"
-
run_dhclient="false"
-
run_ipup="false"
-
-
‘sudo service ddclient start’
-
‘sudo nano /etc/cron.weekly/ddclient’
-
#!/bin/sh
-
/usr/sbin/ddclient -force
-
-
‘sudo chmod +x /etc/cron.weekly/ddclient’
-
‘sudo service ddclient status’ # to check that it is working
-
To force a refresh of the IP address, ‘sudo ddclient -daemon=0 -debug -verbose -noquiet’
-
Setup the VPN server on the RPi:
-
‘curl -L https://install.pivpn.io | bash’
-
Follow the prompts, entering your port number from step A4
-
For Public IP or DNS. Chose DNS and enter your domain name from step B2
-
Choose OpenDNS instead of Google DNS if you are in China (Google is blocked)
-
Be aware that this script will hardcode the RPi’s IP address in /etc/dhcpcd.conf
-
You will have to adjust that file if you switch routers or IP numbers.
-
-
I had to fix the following pivpn script problems:
-
Uses Google DNS
-
‘su’ # superuser
-
‘nano /etc/openvpn/server.conf’
-
change 8.8.8.8 and 8.8.4.4 to
-
i. Open DNS, 208.67.222.222 and 208.67.222.220
ii. Or your local ISP’s DNS server (may be faster if your router is outside the US, step A2)
-
Uses fixed IP address
-
‘su’ # superuser
-
‘nano /etc/openvpn/easy-rsa/pki/Default.txt’
-
change your IP number to your noip domain name (step B2)
-
-
Reboot the RPi
-
Create a OpenVPN profile:
-
‘pivpn add’
-
Enter a profile name and password
-
Look in the profile (in the ovpns directory) with nano and find the text between <key> and </key>
-
Copy all of that to a file called client.key
-
‘openssl rsa -in client.key -des3 -out client.3des.key’
-
Enter your password from step G2 3 times
-
Replace the text between <key> and </key> in the original profile with the entire contents of client.3des.key
-
Copy the edited profile to the phone or computer where you want to use the VPN (use email or flash drive)
-
On the PC or Phone you want to connect:
-
Download any openvpn client
-
Have it use the profile you created in step G8
-
Connect and enter your password
-
You can check the connection on your RPi with ‘pivpn -c’


