Updated: 2022-07
I wrote the first edition of this as a guide for myself at the end of 2017 - it was a mashup of Pi-Hole + PiVPN scripts and an IPsec script installed within a separate Raspian Docker image... and it actually worked!
But things have come a long way, and WireGuard happened - I've since streamlined and simplified my setup into a single Docker Compose script.
The steps below assume the following:
- You have the minimum hardware for running a Raspberry Pi
(I'm still using the same Raspberry Pi 2 over Ethernet) - You know what Pi-Hole is for
- You know what Unbound is for
- You know what WireGuard is for
- You know how to run a Docker Compose script
- Basic networking knowledge (DHCP, IPs, etc.)
- Comfortable around the Terminal / Putty, and text editing config files.
- Install latest Pi OS Lite using the Raspberry Pi Imager
- Either:
Use the Pi Imager options to enable SSH and pre-configure the user credentials (press the Cog button before Write). - Or:
Use the Headless Raspberry Pi steps on the official docs to do the setup manually.
- Either:
- Plug the Pi into the network and power it on
- Once booted, retrieve its initial IP (via router settings, IP scan, etc.) and remote in:
ssh://pi:[email protected]
- Update everything, then run the Configurator:
sudo apt-get update sudo apt-get upgrade -y sudo raspi-config
- Configure base Pi settings to your liking
- (These settings are particularly recommended):
- System Options > Network at Boot: Yes
- Performance Options > GPU Memory: 16
- (These settings are particularly recommended):
- Setup the Pi to use a Static IP Address
- Reboot the Pi and login to the new static IP address
- Install log2ram (Optional, but recommended)
- Install Docker
-
Create the following folders for each app to keep their persistent configs:
mkdir -p ~/docker/pihole-data/etc-dnsmasq.d/ mkdir -p ~/docker/pihole-data/etc-pihole/ mkdir -p ~/docker/unbound-data/ mkdir -p ~/docker/wireguard-data/
-
Navigate into the Unbound config folder:
cd ~/docker/unbound-data/
-
Create the Unbound config file using the example from the Pi-Hole + Unbound docs.
- Instead of saving it as
pi-hold.conf
though, save the config file as:~/docker/unbound-data/unbound.conf
- Instead of saving it as
-
Add the following lines to the bottom of the config file:
# Allow lookups from these blocks (needed when running from inside Docker) access-control: 172.16.0.0/12 allow access-control: 127.0.0.0/8 allow access-control: 10.0.0.0/8 allow access-control: 192.168.0.0/16 allow # Allow Plex DNS things (if using Plex) private-domain: plex.direct
-
Edit and run the compose script below where:
ip.address.of.pi
is the internal static IP of the Piexternal.domain.com
is the external domain or IP of your network (that the VPN client will use to connect on)vpnUser1,vpnUser2
is the comma-separated list of VPN users to create for WireGuard access