(Headless) Rasbperry Pi Setup

  1. Download latest version of Raspbian (Lite) and flash it to an SD card. docs on flashing
  2. Create empty ssh file and place it on boot partition. docs on ssh
    C:\Users\Kain
    >>> E:
    E:\
    >>> touch ssh
    
  3. Create and fill out a wpa_supplicant.conf file and place it on boot partition using the copy (cp) command below. docs on wifi config
    E:\
    >>> cp C:\Users\Kain\Documents\RaspberryPi\wpa_supplicant.conf wpa_supplicant.conf
    
  4. Connect Pi to Router via LAN, and connect power. Pi should boot and flash red power light, and green internet light.
  5. Scan Network to identify IP address of PI, probably corresponding to “Raspberry Pi Foundation”. If on Windows, can use advanced-ip-scanner
  6. SSH into the PI’s IP address using u: pi p: raspberry. If on Windows, can use putty.
  7. Change the default password by running the command passwd. docs on users

Pi Config

Fix Pi to Static IP

Great answers to the question here.

  • Show IP address of PI with ip -4 addr show | grep global.
  • Show IP address of router with ip route | grep default | awk '{print $3}'
  • Edit the config file by running sudo nano /etc/dhcpcd.conf. docs on nano
  • Enter the following essential information (there is a section in the template for this). One section for ethernet connection, and one for WLAN.
    interface eth0
    static ip_address=[YOUR PI IP ADDRESS]
    static routers=[YOUR ROUTER IP ADDRESS]
    static domain_name_servers=[YOUR ROUTER IP ADDRESS]
    
    interface wlan0
    static ip_address=[YOUR PI IP ADDRESS]
    static routers=[YOUR ROUTER IP ADDRESS]
    static domain_name_servers=[YOUR ROUTER IP ADDRESS]
    
  • Ctrl+X to exit nano
  • Type y to save changes when prompted
  • Hit Enter to confirm file for writing and complete exit
  • Reboot the Pi with sudo reboot

Setup DDNS Dynamic Update Client (DUC)

Keep your current IP address in sync with your No-IP host or domain with our Dynamic Update Client (DUC). - no-ip

Full instructions for no-ip service here: https://www.noip.com/support/knowledgebase/install-ip-duc-onto-raspberry-pi/

Setup OpenVPN Client

Using PiVPN

  1. SSH into your pi and install pivpn with curl -L https://install.pivpn.io | bash
  2. You can confirm default settings for most options. When prompted, enter your own domain name. You can get a free one from noip
  3. Check that the service is running sudo service openvpn status
  4. Create a new client certificate by running pivpn add and giving it a password
  5. Copy the certificate file from pi to the device you want to connect from. If on Windows, can use filezilla
  6. Next, configure your DDNS service on your router. If you are using a two router setup (modem/router), do this on the router acting as a modem where the internet comes in first.
  7. Lastly, forward the OpenVPN service port on your router, the default port from piVPN is 1194. Important note here, OpenVPN uses UDP as the protocol. If you are using a two router setup (modem/router) you may need to first forward traffic on that port to the second router, to then be forwarded to the pi.

Useful PiVPN commands:

  • List certificates with pivpn list
  • Revoke a compromised certificate with pivpn revoke
  • Add a new certificate with pivpn add optionally with nopass for no password
  • List connected clients with pivpn -c
  • Reboot the openvpn server with sudo service openvpn reboot

  • Note that the VPN server automatically starts after a reboot, so nothing is needed if power to the pi cuts out temporarily