@DerFetzer, thanks a lot for this detailed post. But I am still having a problem regarding the DHCP in the Pihole.
Background
Like you, I had the Pihole flawlessly working on my raspberry pi before. Similarly, I moved to NUC and did a setup from scratch with docker-compose
. However, I could not get the DHCP to work. I followed your setup and the Pihole is starting without a problem. When I manually set the DNS configuration on a device to hit the Pihole, ads are blocked successfully. However, I wanted to move away from this manual DNS configuration and have the Pihole be the DHCP server (this is because I live in the UK, and Virgin Media Hub modems don't let you assign a DNS server and it is painful to change the DNS settings manually. Also, there are many IoT devices whose DNS cannot be configured manually and those devices are still sending telemetry data). Things started going wrong when I enabled DHCP on the Pihole:
What I tried
- When the DHCP on my Virgin Hub (router) AND the DHCP on my Pihole are ON at the same time, I see that my Pihole starts leasing IPs. However, when a new device joins the network, it is not guaranteed that the Pihole will lease the IP to that device hence no adblocking. Not to mention having 2 DHCPs running in the network is a recipe for problems.
- When I turn off the DHCP on my router AND have the Pihole serve as the only DHCP server, I cannot browse as I receive a DNS-related error in the Chrome web browser, nor can I launch the web UI for the Pihole.
- I thought maybe switching from 2 DHCPs to 1 DCHP might be causing this problem. So I turned off both DHCPs, attached a monitor to my NUC, and tried to launch the Pihole. No luck once again, and I saw in
docker-compose up
that there is a problem with DNS configuration and the Pihole launch gets stuck there. Then I opened a new terminal session in the NUC and tried toping
a device in the network that I know is connected to the internet (my desktop), but it said network failure, the NUC was not even connected to the internet. However, both on the Pihole and on my Virgin Hub, the NUC is configured to receive the static IP of192.168.0.2
.
Current setup
Currently, I turned off the DHCP on my NUC and I am only using it for adblocking by manually configuring the DNS in my devices, as I mentioned before, the adblocking is working without a problem.
Information
docker-compose.yml
version: "3"
services:
pihole:
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "53:53/udp"
- 81:80
restart: "always"
cap_add:
- NET_ADMIN
dns:
- 127.0.0.1
- 1.1.1.1
environment:
TZ: "Europe/London"
ServerIP: 192.168.0.2
DNS1: 1.1.1.1
DNS2: 1.0.0.1
VIRTUAL_HOST: pi.hole
DNSMASQ_LISTENING: all
INTERFACE: eth0
DHCP_ACTIVE: "true"
DHCP_START: "192.168.0.2"
DHCP_END: "192.168.0.200"
DHCP_ROUTER: "192.168.0.1"
volumes:
- ./pihole/:/etc/pihole/
- ./dnsmasq.d/:/etc/dnsmasq.d/
- ./logs:/var/log/pihole/
depends_on:
- dhcphelper
networks:
backend:
ipv4_address: '172.31.0.100'
dhcphelper:
build: ./dhcp-helper
restart: "always"
network_mode: "host"
command: -s 172.31.0.100
cap_add:
- NET_ADMIN
networks:
backend:
ipam:
config:
- subnet: 172.31.0.0/16
Dockerfile
FROM alpine:latest
RUN apk --no-cache add dhcp-helper
EXPOSE 67 67/udp
ENTRYPOINT ["dhcp-helper", "-n"]
/etc/netplan/00-installer-config.yaml
Instructions I followed to address the port 53 bind issue, and as a result changes were made to this /etc/netplan
.
# This is the network config written by 'subiquity'
network:
ethernets:
enp89s0:
dhcp4: true
dhcp4-overrides:
use-dns: false
match:
macaddress: <some-mac-address>
set-name: eth0
nameservers:
addresses: [127.0.0.1]
version: 2