Skip to content

Instantly share code, notes, and snippets.

@kevincolten
Last active September 4, 2018 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevincolten/5efa9d47a0ab7253bf401070086e2723 to your computer and use it in GitHub Desktop.
Save kevincolten/5efa9d47a0ab7253bf401070086e2723 to your computer and use it in GitHub Desktop.
Setting up PIA and OpenVPN on a Raspberry Pi
  1. sudo apt-get update

  2. sudo apt-get upgrade -y

  3. sudo apt-get install openvpn unzip dnsutils geoip-bin -y

  4. (mkdir openvpn && cd openvpn && unzip ../openvpn.zip)

  5. ( echo username; echo password; ) | tee /home/pi/openvpn/pass.txt

  6. ( echo auth-user-pass pass.txt; echo auth-nocache;) | tee --append US\ East.ovpn

  7. sudo nano /etc/init.d/VPNConnection

#! /bin/sh
# /etc/init.d/VPNConnection

### BEGIN INIT INFO

# Short-Description: Simple script to start a program at boot
# Description:       A simple script from http://www.stuffaboutcode.com
### END INIT INFO

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting VPN Connection"
# Connect to the VPN
(cd /home/pi/openvpn && sudo openvpn US\ East.ovpn)
;;
stop)
echo "Stopping VPN Connection"
# Disconnect
killall openvpn
;;
*)
echo "Usage: /etc/init.d/VPNConnection {start|stop}"
exit 1
;;
esac
  1. sudo chmod 755 /etc/init.d/VPNConnection

To test:

  1. sudo /etc/init.d/VPNConnection start
  2. sudo /etc/init.d/VPNConnection stop

To start at boot: sudo update-rc.d VPNConnection defaults

To remove from boot: sudo update-rc.d -f VPNConnection remove

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

gunzip GeoLiteCity.dat.gz

echo 'geoiplookup -f ~/GeoLiteCity.dat $(dig +short myip.opendns.com @resolver1.opendns.com)' | tee --append .bash_profile

  1. Disable IPv6 source
    1. Disable IPv6 via sysctl
      1. echo net.ipv6.conf.all.disable_ipv6=1 | sudo tee --append /etc/sysctl.conf
    2. Comment out any IPv6 hosts in your /etc/hosts file
      1. sudo nano /etc/hosts
      2. #::1 localhost ip6-localhost ip6-loopback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment