Skip to content

Instantly share code, notes, and snippets.

@chriscasola
Last active June 13, 2020 02:36
Show Gist options
  • Save chriscasola/3cede62932990ddeee519552c2643884 to your computer and use it in GitHub Desktop.
Save chriscasola/3cede62932990ddeee519552c2643884 to your computer and use it in GitHub Desktop.
PiVPN / Pi-Hole Setup on Raspberry Pi

Install PiVPN - https://pivpn.io/

  1. sudo -i
  2. vi /etc/wireguard/wg0.conf
  3. Add DNS = 10.6.0.1 (the wireguard IP of the Pi)
  4. Add this to forward all traffic to the internet
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

Install PiHole - https://pi-hole.net/

  1. Make sure to bind to all interfaces. If you don't do this during setup you can do it in the web UI in "Settings -> DNS -> Interface listening behavior"

Configure Mobile Device

  1. Scan QR code from pivpn --qr after adding the client
  2. To forward only DNS set Allowed IPs to 10.6.0.1/32 in the wireguard app
  3. Set DNS servers to "10.6.0.1" in the wireguard app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment