Skip to main content

Pi-hole - Docker Compose, Setup a DNS Sinkhole with VMware Workstation

321 words·
Pi-hole DNS Sinkhole Docker-Compose VMware

Prerequisites
#

In this setup I’m using VMware Workstation Pro 17.5 on Windows 11. I’m setting up Pi-hole on a Debian 12 VM with the following IP address 192.168.50.2. The Debian VM automatically starts after the Windows login.

I achieved great results by combining Pi-hole with the Brave browser.

Pi-hole
#

Folder Structure
#

# Create folder structure
sudo mkdir -p /opt/pihole && cd /opt/pihole

Docker Compose File
#

# Create Docker Compose file
sudo vi docker-compose.yml
version: "3.9"
services:

  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
    environment:
      TZ: 'Europe/Vienna'
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    cap_add:
      - NET_ADMIN
    restart: unless-stopped
# Create / start Docker container
sudo docker compose up -d

Change Pi-hole Password
#

# Exec container terminal
sudo docker exec -it pihole bash

# Change password
pihole -a -p newpassword

# Exit container terminal
exit

Webinterface
#

Login with the password defined in the previous step, it is not necessary to define a username.

# Open webinterface
192.168.50.2/admin/

Upstream DNS Server
#

Go to Settings > DNS

  • Define upstream DNS servers

  • Click Save


Client DNS Server (Windows)
#

  • Define the IP of the Debian VM as the DNS server in the Windows network interface

  • Optional: Use PowerShell to check if the correct DNS server is defined

# List DNS server with PowerShell
Get-DnsClientServerAddress

# Shell output:
InterfaceAlias               Interface Address ServerAddresses
                             Index     Family
--------------               --------- ------- ---------------
Ethernet1                           10 IPv4    {192.168.50.2}
Ethernet1                           10 IPv6    {}
Loopback Pseudo-Interface 1          1 IPv4    {}
Loopback Pseudo-Interface 1          1 IPv6    {}

VMware
#

VM Autostart
#

Enable the auto startup of the Debian vm when the Windows user logs in:

# Open the Windows startup folder for the current user: Run
shell:startup

# Create a shortcut with the location pointing to vmware.exe and the vmx file of the Pi-Hole vm 
"C:\Program Files (x86)\VMware\VMware Workstation\vmware.exe" -x "F:\VMs\VLAN-50\Debian_Pi-hole\Deb-Pi-hole.vmx"

Links #

# Official Documentation
https://github.com/pi-hole/docker-pi-hole#note-on-capabilities

# Brave Browser Download
https://brave.com/download/