Skip to content

Valendrew/pihole-wireguard-gen

Repository files navigation

Stargazers Issues MIT License


Logo

Pi-hole + Wireguard

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Post setup
  5. TODO
  6. License
  7. Contact
  8. Acknowledgments

About The Project

TODO

(back to top)

Built With

  • Pihole
  • Wireguard
  • Pigen

(back to top)

Getting Started

To get a local copy up and running follow these example steps.

  • Clone
    git clone --recurse-submodules URL

Containers configuration

Create a .env file at stage2-custom/00-docker/files, with a structure as follows:

Variable Description
DEVICE_IP IP address of the device
WIREGUARD_HOST The public hostname of the VPN server[1]
WIREGUARD_PASSWORD Password for the WireGuard Web UI[1]
WIREGUARD_PORT The host public UDP port for WireGuard[1]
PIHOLE_PASSWORD Password for Pi-hole Web UI[2]
PIHOLE_PORT Port for Pi-hole Web UI[2]
PIHOLE_API_KEY API key for Pi-hole[2]
HOMEPAGE_PORT Port for the homepage WEB UI[3]

[1]: Wireguard options.

[2] : Pi-hole options.

[3] : Homepage options.

Note: The variable PIHOLE_API_KEY is set only after containers have been created, by generating the key at Pi-hole WEB UI -> Settings -> API -> Show API token.

pi-gen configuration

Create a .config file in the root directory, with a structure as explained in the Pi-gen documentation

Note: A configuration file example is provided in the root directory as .config.example, which can be renamed to .config, and used as is after editing the empty variables.

Variable Description
PUBKEY_SSH_FIRST_USER SSH public key for the user
SSH_PORT SSH port

Usage

Create the image

   ./build-image.sh

(back to top)

Flash the image to an SD card using a tool such as Raspberry Pi Imager or balenaEtcher and insert it into the Raspberry Pi.

Post setup

  • Router configuration
    • Set device IP to DEVICE_IP as static
    • Port forward the DEVICE_IP in your router to access Wireguard for an external network.
  • RaspberryPi configuration
    • You will be prompted to configure the keyboard layout, user and password on first boot.
    • Edit the SSH port by running sudo nano /etc/ssh/sshd_config and changing the line #Port 22 to Port SSH_PORT.
  • Create the containers
    • Run docker compose up -d in ~/project/docker to create the containers.
    • Generate the API key for Pi-hole at Pi-hole WEB UI -> Settings -> API -> Show API token and set it in the .env file.
    • Restart the containers by running docker compose restart in ~/project/docker to apply the changes.

Access at the homepage at http://DEVICE_IP:HOMEPAGE_PORT, from where you can access the Pi-hole and Wireguard WEB UIs.

TODO

  • Edit SSH port directly in stage2-custom instead of post setup

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Contact me for any questions or suggestions at LinkedIn

(back to top)

Acknowledgments

  • Logo designed by Hopstarter from Flaticon
  • Pi-hole, Wireguard and pi-gen

(back to top)