- Shell 100%
| config/pihole | ||
| firewall | ||
| .env.example | ||
| .gitignore | ||
| bootstrap.sh | ||
| COMPLIANCE.md | ||
| docker-compose.yml | ||
| README.md | ||
BCS_PiHole_Project
Standalone Pi-hole DNS sinkhole with an AdGuard DNS-over-HTTPS (DoH) proxy sidecar.
This is a clean, deployable extraction of the Pi-hole + dnsproxy setup originally built for the Sawgrass Security Dashboard.
What it does
- Pi-hole (
pihole/pihole:latest) provides network-wide ad blocking, tracker blocking, and local DNS resolution. - dnsproxy (
adguard/dnsproxy:latest) runs on127.0.0.1:5335and forwards all upstream queries to Cloudflare via encrypted DNS-over-HTTPS. - Pi-hole forwards its upstream queries to the local dnsproxy only — there is no plaintext fallback. If dnsproxy is unavailable, DNS resolution stops (fail closed) rather than leaking unencrypted queries upstream.
Ports
| Port | Protocol | Purpose |
|---|---|---|
| 53 | TCP + UDP | DNS service for clients |
| 8080 | TCP | Pi-hole web admin interface |
| 5335 | TCP | Internal DoH proxy (localhost only) |
Requirements
- Linux host with Docker and Docker Compose v2
hostnetworking enabled (Pi-hole must bind directly to the host interface)- Firewall/UFW configured to allow inbound TCP/UDP 53 and TCP 8080 from trusted sources
- A static host IP recommended (
SERVERIPin.env)
Configuration
- Copy the example environment file and edit it:
cp .env.example .env
nano .env
- Set the required variables in
.env(see.env.examplefor the full list):
| Variable | Required | Description |
|---|---|---|
PIHOLE_PASSWORD |
✅ | Password for the Pi-hole web admin (compose fails without it) |
SERVERIP |
✅ | LAN IP of the host; the web admin binds to this address only |
FTL_PRIVACY_LEVEL |
— | Query-log privacy level (default 2 = hide domains in logs, GDPR data-minimization) |
FTL_DB_RETENTION_DAYS |
— | Long-term query DB retention in days (default 30, GDPR storage limitation) |
PIHOLE_IMAGE / DNSPROXY_IMAGE |
— | Pin exact image tags/digests for production |
PUID, PGID, and TZ are set directly in docker-compose.yml.
Host preparation
This project is designed for a dedicated Pi-hole host using network_mode: host. On such a host, systemd-resolved binds port 53 and will prevent Pi-hole from starting.
Run the provided host-prep script as root before the first deploy:
sudo ./bootstrap.sh
Or manually stop and disable systemd-resolved and point /etc/resolv.conf to 127.0.0.1.
⚠️ Only do this on a host where this Pi-hole instance is intended to be the DNS resolver. Rewriting
/etc/resolv.confcan break DNS on shared or desktop systems.
Deploy
cd /home/secbeard/.openclaw/workspace/projects/BCS_PiHole_Project
docker compose up -d
Verify the containers are running:
docker compose ps
docker logs bcs-pihole
docker logs bcs-pihole-dnsproxy
If Pi-hole fails to start with a port 53 "Address in use" error, the host may already have another DNS resolver or a Sawgrass setup.sh DNS watchdog running. Stop or disable the conflicting service before deploying.
Pi-hole v6 runs as non-root UID 1000, so this compose file adds cap_add: [NET_BIND_SERVICE, NET_ADMIN, NET_RAW, SYS_NICE, SYS_TIME] so the container can bind privileged port 53 and manage DNS sockets. Without these capabilities, port binding will fail.
Web admin port
The web admin port is set to 8080. In Pi-hole v6 the legacy WEBPORT environment variable is no longer honored; the compose file uses FTLCONF_webserver_port so FTL overrides webserver.port in pihole.toml at runtime.
First use
- Open the Pi-hole admin panel at
http://<SERVERIP>:8080/admin - Log in with the password set in
.env(PIHOLE_PASSWORD) - Point client devices to
<SERVERIP>for DNS
Internal-only deployment
This stack is designed to be reachable only from the local network:
- The web admin UI binds to
${SERVERIP}(the LAN IP set in.env) — never0.0.0.0. DNSMASQ_LISTENING: localmakes dnsmasq accept queries only from origins on the local subnet.- A ready-made firewall script enforces RFC1918-only access — review it and adjust the subnets to your actual LAN, then run:
sudo ./firewall/ufw-internal-only.sh
⚠️ Never port-forward 53 or 8080 to the internet. No router port-forwards, no direct container publishes — this deployment is internal-only by design.
Compliance
This repo ships a HIPAA/GDPR-oriented control map in COMPLIANCE.md: access control, audit logging with capped retention, pin-able images, encrypted DoH upstream, data-minimization defaults (FTL_PRIVACY_LEVEL=2), and an erasure procedure for query data. These are technical controls only — organizational compliance (BAAs, DPIAs, policies) remains the operator's responsibility.
Networking notes
- Both services use
network_mode: hostso Pi-hole can listen on the host's real interfaces and dnsproxy can bind127.0.0.1:5335from the host network namespace. DNSMASQ_LISTENING: localtells dnsmasq to accept only queries that originate from the local subnet.- The web admin port is set to
8080viaFTLCONF_webserver_portbecause Pi-hole v6 does not honor the legacyWEBPORTvariable.
Firewall / security
Use the provided internal-only policy script (review and adjust the subnets first):
sudo ./firewall/ufw-internal-only.sh
It allows 53/tcp, 53/udp, and 8080/tcp only from RFC1918 ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), explicitly denies those ports from everything else, guards SSH access before enabling ufw, and then enables the firewall.
The dnsproxy DoH sidecar listens only on 127.0.0.1:5335, so it is not externally reachable.
Updating
docker compose pull
docker compose up -d
Upgrading an existing deployment (pre-hardening → hardened)
After git pull on an already-deployed instance:
- Update
.envwith the new variables from.env.example—PIHOLE_PASSWORDis now required (compose refuses to start without it). - Recreate the stack:
docker compose up -d.
Do not run docker compose down -v unless you intentionally want a full reset — it erases gravity and query data.
Stopping
docker compose down # stop containers, keep volumes
docker compose down -v # stop and delete volumes (resets Pi-hole data!)