There is two main ways in which PiHole can be installed. The first is barebones, installing PiHole directly onto a unix based system (Ubuntu in my case). The other and my personally preferred way is Docker. We will start with the barebones as it is a bit of a simpler guide:
Direct install
Following the very simple guide on PiHole’s GitHub page here:
https://github.com/pi-hole/pi-hole/#one-step-automated-install
All you need to do to get started is run: curl -sSL https://install.pi-hole.net | bash
This will then give you a simple process in order to install PiHole into your network. Further down I will explain how to get using it under the “Additional Setup” heading.
Docker install
In this guide I will be using docker compose at it is by far the easiest way to create a container. First, start my creating a docker compose file, I will include mine below for ease:
# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
pihole:
container_name: pihole-docker
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "53:53/udp"
#- "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
- "82:80/tcp"
environment:
TZ: 'Europe/London'
# WEBPASSWORD: 'set a secure password here or it will be random'
# Volumes store your data between container upgrades
volumes:
- './etc-pihole:/etc/pihole'
- './etc-dnsmasq.d:/etc/dnsmasq.d'
# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
# cap_add:
# - NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed
restart: unless-stopped
labels:
- "com.centurylinklabs.watchtower.enable=false" #this is needed to disable watchtower
The only additions I have made to the normal compose file, is that I have added:
labels:
- "com.centurylinklabs.watchtower.enable=false"
This tells the Watchtower updating app to ignore PiHole, which is very important to stop it being auto updated at random times. If you did want this auto updating using Watchtower then remove these lines.
Additional Setup
You will need to set your internal DNS resolver to point at your new PiHole Server, this will be different depending on router but for a Unifi setup it goes as follows:
- Go to https://unifi.ui.com/
- Go to settings
- Go to internet
- Change DNS server to manual
- Enter the IP address(s) of your new PiHole servers
- Check DNS traffic is correctly being passed.
Update 23/12/2024: I will be creating additional guides that I will link here to show to to stop DNS bypass of PiHole.
Be sure to check out our other Cyber Security posts for more information:
Leave a Reply