Reads Traefik routers
Host() rules of HTTP routers and optionally HostSNI() rules of TCP routers, across every page of the Traefik API.
traefik-pihole-sync
StableHomelab · open source · Traefik & Pi-hole v6
traefik-pihole-sync keeps the local DNS records of Pi-hole in sync with your Traefik routers. Start a container with a Host() rule and its name resolves on your network a minute later; remove it and the record goes away again.
Free under MIT · Small non-root container · amd64 and arm64
Host(`grafana.lan`)A grafana.lan 192.168.1.10Host(`wiki.lan`)A wiki.lan 192.168.1.10Host(`photos.lan`)CNAME photos.lan nas.lanHost(`test.lan`)container gone → record removedEvery minute it reads the routers from the Traefik API, keeps the hostnames inside your domains and adds what is missing in Pi-hole.
Host() rules of HTTP routers and optionally HostSNI() rules of TCP routers, across every page of the Traefik API.
Point hostnames at an IPv4 and/or IPv6 address, or make them CNAMEs of your proxy host.
Keep more than one Pi-hole in sync at once, each with its own password and state.
Only names inside the domains you list, so a typo can never hijack someone else's domain on your network.
Changes and problems at INFO, a status line per hour, repeated errors only once.
Runs without root, built-in health check, logs out of Pi-hole on shutdown.
Set the Traefik API, your Pi-hole, the target IP and your domains in the compose file, put the Pi-hole password in a secret, then start it.
# compose.yaml (shortened) – see the README for the secret and network
services:
traefik-pihole-sync:
image: ghcr.io/schnuecks/traefik-pihole-sync:latest
restart: unless-stopped
environment:
TRAEFIK_API_URL: http://traefik:8080
PIHOLE_URL: https://pihole.example.com
PIHOLE_PASSWORD_FILE: /run/secrets/pihole_password
TARGET_IP: 192.0.2.10
DOMAINS: example.com
DRY_RUN: "true"
secrets: [pihole_password]
volumes: [./data:/data]
If one of my projects saves you time, you can buy me a coffee on Ko-fi. It keeps the printers running and the next idea coming.