Notes On Raspberry Pi
- (Headless) Rasbperry Pi Setup
- Pi Config
- Fix Pi to Static IP
- Setup DDNS Dynamic Update Client (DUC)
- Setup OpenVPN Client
(Headless) Rasbperry Pi Setup
- Download latest version of Raspbian (Lite) and flash it to an SD card. docs on flashing
- Create empty
ssh
file and place it on boot partition. docs on sshC:\Users\Kain >>> E: E:\ >>> touch ssh
- Create and fill out a
wpa_supplicant.conf
file and place it on boot partition using the copy (cp
) command below. docs on wifi configE:\ >>> cp C:\Users\Kain\Documents\RaspberryPi\wpa_supplicant.conf wpa_supplicant.conf
- Connect Pi to Router via LAN, and connect power. Pi should boot and flash red power light, and green internet light.
- Scan Network to identify IP address of PI, probably corresponding to “Raspberry Pi Foundation”. If on Windows, can use advanced-ip-scanner
- SSH into the PI’s IP address using u:
pi
p:raspberry
. If on Windows, can use putty. - Change the default password by running the command
passwd
. docs on users
Pi Config
- run
sudo raspi-config
to configure the PI. docs on 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
- SSH into your pi and install pivpn with
curl -L https://install.pivpn.io | bash
- You can confirm default settings for most options. When prompted, enter your own domain name. You can get a free one from noip
- Check that the service is running
sudo service openvpn status
- Create a new client certificate by running
pivpn add
and giving it a password - Copy the certificate file from pi to the device you want to connect from. If on Windows, can use filezilla
- 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.
- 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 withnopass
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