Ceci est une ancienne révision du document !
Il n'est plus nécessaire de présenter pi-hole.net tant cet outil rends le contrôle et la réduction des trackers/publicité facile.
En migrant mon instance pi-Hole vers docker, je me suis heurté à un soucis imprévu, l'image officielle ne contient pas de serveur “upstream” intégré; elle est parfaitement fonctionnelle avec des DNS upstream tel que google, quad9, cloudflare, mais si l'on veut réellement être indépendant, il manque son propre référentiel.
Avec docker, il est très facile d'ajouter un container “unbound” et de le configurer en serveur upstream, pour ensuite faire pointer pi-Hole sur ce container.
J'ai décidé de composer mon propre “stack” pour lier les deux containers tout en gardant une configuration un peu particulière: je veux que le serveur unbound soit sur un port différent : 5335 du serveur dns.
Les raisons sont multiples, mais la plus évidente est d'éviter que unbound soit publier par accident sur le réseau (ce DNS serveur n'est absolument pas filtré et peut donc présenter des risques importants).
networks: infrastructure: external: true name: "infrastructure" services: unbound: cap_drop: - "AUDIT_CONTROL" - "BLOCK_SUSPEND" - "DAC_READ_SEARCH" - "IPC_LOCK" - "IPC_OWNER" - "LEASE" - "LINUX_IMMUTABLE" - "MAC_ADMIN" - "MAC_OVERRIDE" - "NET_ADMIN" - "NET_BROADCAST" - "SYSLOG" - "SYS_ADMIN" - "SYS_BOOT" - "SYS_MODULE" - "SYS_NICE" - "SYS_PACCT" - "SYS_PTRACE" - "SYS_RAWIO" - "SYS_RESOURCE" - "SYS_TIME" - "SYS_TTY_CONFIG" - "WAKE_ALARM" command: - "/unbound.sh" healthcheck: test: drill @127.0.0.1 -p 5335 cloudflare.com || exit 1 interval: 30s timeout: 30s retries: 3 start_period: 10s container_name: dns_unbound environment: - "PATH=/opt/unbound/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - "NAME=unbound" - "SUMMARY=is a validating, recursive, and caching DNS resolver." - "DESCRIPTION=is a validating, recursive, and caching DNS resolver." - "TZ=Europe/Brussels" expose: - "5335/tcp" - "5335/udp" hostname: "97b5d3c8a2cc" image: "mvance/unbound:latest" ipc: "private" labels: maintainer: "Matthew Vance" org.opencontainers.image.description: "a validating, recursive, and caching DNS resolver" org.opencontainers.image.licenses: "MIT" org.opencontainers.image.source: "https://github.com/MatthewVance/unbound-docker" org.opencontainers.image.title: "mvance/unbound" org.opencontainers.image.url: "https://github.com/MatthewVance/unbound-docker" org.opencontainers.image.vendor: "Matthew Vance" org.opencontainers.image.version: "" logging: driver: "json-file" options: {} networks: infrastructure: ipv4_address: 172.20.0.200 restart: "unless-stopped" volumes: - "unbound-etc:/opt/unbound/etc/unbound" working_dir: "/opt/unbound" dns-pihole: cap_drop: - "AUDIT_CONTROL" - "BLOCK_SUSPEND" - "DAC_READ_SEARCH" - "IPC_LOCK" - "IPC_OWNER" - "LEASE" - "LINUX_IMMUTABLE" - "MAC_ADMIN" - "MAC_OVERRIDE" - "NET_ADMIN" - "NET_BROADCAST" - "SYSLOG" - "SYS_ADMIN" - "SYS_BOOT" - "SYS_MODULE" - "SYS_NICE" - "SYS_PACCT" - "SYS_PTRACE" - "SYS_RAWIO" - "SYS_RESOURCE" - "SYS_TIME" - "SYS_TTY_CONFIG" - "WAKE_ALARM" container_name: dns_pihole entrypoint: - "/s6-init" environment: - "PATH=/opt/pihole:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - "phpver=php" - "PHP_ERROR_LOG=/var/log/lighttpd/error-pihole.log" - "IPv6=True" - "S6_KEEP_ENV=1" - "S6_BEHAVIOUR_IF_STAGE2_FAILS=2" - "S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0" - "FTLCONF_LOCAL_IPV4=0.0.0.0" - "FTL_CMD=no-daemon" - "DNSMASQ_USER=pihole" - "TZ=Europe/Brussels" - "WEBPASSWORD=Mdr2Pq3*" hostname: "pi-Hole" image: "pihole/pihole:latest" ipc: "private" labels: org.opencontainers.image.created: "2024-06-16T19:54:20.386Z" org.opencontainers.image.description: "Pi-hole in a docker container" org.opencontainers.image.licenses: "NOASSERTION" org.opencontainers.image.revision: "4149693092ea364c7aab6c30ba0b308e4bc45716" org.opencontainers.image.source: "https://github.com/pi-hole/docker-pi-hole" org.opencontainers.image.title: "docker-pi-hole" org.opencontainers.image.url: "https://github.com/pi-hole/docker-pi-hole" org.opencontainers.image.version: "2024.06.0" logging: driver: "json-file" options: {} networks: infrastructure: ipv4_address: 172.20.0.201 ports: - "53:53/tcp" - "53:53/udp" - "81:80/tcp" restart: "unless-stopped" volumes: - "pihole_config:/etc/pihole" - "pihole_dnsmasq:/etc/dnsmasq.d" volumes: unbound-etc: pihole_config: pihole_dnsmasq: