Pi‐hole Setup Guide - ajgillis04/GillisDockerDepot GitHub Wiki

Pi-hole Setup Guide

Introduction

Pi-hole is a network-wide ad blocker that acts as a DNS sinkhole, blocking ads and tracking domains for all devices connected to your network.

Prerequisites

  • Docker installed
  • Pi-hole container running in your Docker stack

Configuration Steps

Step 1: Accessing the Pi-hole UI

  1. Open your browser and navigate to http://<your-piholeip-address>. This was set in .env.
  2. Log in with your Pi-hole credentials.

Step 2: Initial Setup Wizard

  1. Follow the initial setup wizard to configure basic settings.
  2. Choose your preferred language for the Pi-hole interface.

Step 3: Configuring DNS Settings

  1. Navigate to the Settings tab.
  2. Go to the DNS section.
  3. Configure the DNS settings, including upstream DNS servers and custom DNS entries.
  4. Click Save.

Step 4: Adding Block Lists

  1. Navigate to the Group Management tab.
  2. Go to the Adlists section.
  3. Click Add to add new block lists.
  4. Enter the URL of the block list you want to add.
  5. Click Save.

Step 5: Configuring Clients

  1. Go to the Clients tab.
  2. Click Add Client.
  3. Enter the IP address or hostname of the client device.
  4. Configure client-specific settings, such as group assignment and DNS rules.
  5. Click Save.

Step 6: Monitoring and Managing Queries

  1. Navigate to the Dashboard tab.
  2. Monitor blocked queries, total queries, and top domains.
  3. Use the various tabs to view query logs, client activity, and block lists.

Setting Up Pi-hole on Raspberry Pi

⚠️ Hint: Redundancy is good practice. If your main Pi-hole goes offline, it will impact your network.

Prerequisites

  • Raspberry Pi with Raspberry Pi OS
  • Docker installed

Step-by-Step Instructions

Prepare Your Raspberry Pi

  1. Download and Install Raspberry Pi OS:
    • Download and install the Raspberry Pi Imager from Raspberry Pi Imager to install Raspberry Pi OS on a microSD card.

    • Launch Raspberry Pi Imager from your start menu and select the device, operating system, and storage, then click Next. Note: Your selections may be different than mine depending on hardware

      Pi-hole Imager

    • Choose Edit Settings.

    • In the General blade, select Enable SSH.

      Pi-hole General1

    • In the Services blade, select the hostname, and set the username and password.

      Pi-hole Services

    • Insert the microSD card into your Raspberry Pi and boot it up.

Optional

  1. Set Static IP for the Raspberry Host machine: I set a static address so i can always reach the the Raspberry host even if dhcp is down. Raspberry actually recommends setting a DCHP reservation on you router

    • On the host desktop go to the top right and *right click icon that looks like blue up and down arrows

    • Choose Network Manager Settings, and set static ip, subnet, and dns servers. I use my pihole servers as the DNS

      Pi-hole Static

  2. Update Your Raspberry Pi:

    • Putty into the Raspberry Pi and run these commands:
    sudo apt update
    sudo apt upgrade -y

Install Docker and set your GIT on Your Raspberry Pi

  1. Install Docker:

    • Install Docker:
    curl -sSL https://get.docker.com | sh
    sudo usermod -aG docker $USER
    sudo reboot
  2. Install Git on Your Raspberry Pi:

    sudo apt install git -y
  3. Clone Your Repository:

    • Clone:
    cd /usr/local
    sudo git clone https://<your-token>@github.com/yourusername/GillisDockerDepot.git
    cd GillisDockerDepot
    sudo chown -R {yourusername}:{yourusername} /usr/local/GillisDockerDepot     
    sudo chmod -R 775 /usr/local/GillisDockerDepot
  4. (Optional) Install & Update the Samba Configuration:

    • Run the following commands:
    sudo apt install samba -y
    sudo nano /etc/samba/smb.conf
    • Add the Share Configuration: Add the following lines at the end of the file to define your share:
    [GillisDockerDepot]
    path = /usr/local/GillisDockerDepot
    browseable = yes
    read only = no
    valid users = <your-username>
    
    • Create a Samba Password for : Add the user to Samba and set a password:
    sudo smbpasswd -a <your-username>
    • Restart Samba Services: After saving your changes to the configuration file, restart the Samba services:
    sudo systemctl restart smbd
    sudo systemctl restart nmbd
  5. Access the Shared Directory:

    • Access the shared directory from your Windows machine by typing \\<RaspberryIP>\GillisDockerDepot in the File Explorer address bar.
    • I copy over any files that are not part of the git repository like .env, traefik yamls, and shared folder.
  6. Update .env

    • Either create or modify the .env file to update paths and environment variables for this server.

**⚠️ Hint: to get the PUID and PGID run these and copy into your .env

id <username>
  1. Update docker-compose-server{num}.yaml
  2. Start Containers
    docker compose -p mediaserver -f docker-compose-server{num}.yaml up --detach

Setting Up Pi-hole with Redundancy and Syncing Configuration

1. Setting Up Multiple Pi-hole Instances

**⚠️ Hint: Ensure you have `Expert' turned on

Primary Pi-hole

  1. Go to Settings, All settings, Miscellaneous

  2. Find the misc.dnsmasq_lines section and add

    dhcp-option=6,<DNS_Server1_IP>,<DNS_Server2_IP>
    
  3. Select Save & Apply

  4. Repeat on Pihole 2 if you do not have a sync between the systems in place

2. Verifying DHCP Clients Receive Both DNS Servers

Windows

  1. Open Command Prompt: Press Win + R, type cmd, and press Enter.
  2. Check IP configuration:
    ipconfig /all
    
  3. Look for DNS Servers (Example below):
    • Verify that <primary Pi-hole IP> and <secondary Pi-hole IP> are listed.
    Default Gateway . . . . . . . . . : 192.168.1.1
    DHCP Server . . . . . . . . . . . : 192.168.1.5
    DNS Servers . . . . . . . . . . . : 192.168.1.5
                                        192.168.1.6
    
    

macOS

  1. Open Terminal: Press Cmd + Space, type Terminal, and press Enter.
  2. Check IP configuration:
    networksetup -getdnsservers <network_interface>
  3. Look for DNS Servers: Verify that <primary Pi-hole IP> and <secondary Pi-hole IP> are listed.

Linux

  1. Open Terminal: Open a terminal application.
  2. Check resolved configuration:
    nmcli device show <network_interface> | grep IP4.DNS
  3. Look for DNS Servers: Verify that <primary Pi-hole IP> and <secondary Pi-hole IP> are listed.

3. Exporting and Importing Settings with Teleporter

Exporting Settings

  1. Open the Pi-hole admin interface for the primary Pi-hole (<primary Pi-hole IP>).
  2. Navigate to Settings > Teleporter.
  3. Click Backup to export the settings.
  4. Download the backup file to your local machine.

Importing Settings

  1. Open the Pi-hole admin interface for the secondary Pi-hole (<secondary Pi-hole IP>).
  2. Navigate to Settings > Teleporter.
  3. Click Restore and choose the backup file you exported.
  4. Click Restore to import the settings.

By following these steps, you can set up multiple Pi-hole instances with redundancy, synchronize configuration, and ensure that DHCP clients receive both DNS servers. Additionally, you can use the Teleporter feature to export and import settings between Pi-hole instances.

⚠️ **GitHub.com Fallback** ⚠️