Two PiHole servers and extra hosts

I have two pihole servers running, and each of them have extra host entries. My “main” server is running in a container on my workhorse machine. My “backup” server is running on a RPI like machine.

Occasionally the main server goes down when I’m fiddling. My router points to main as the primary and the backup as the secondary dns.

When both are running, I can only see the extra hosts on the main pihole. If main goes down, I can see the hosts on the backup. What can I do (other than copying the host entries) so that I can always see the extra hosts on both servers?

Please elaborate, and provide examples.

Let’s say my “main” server is running several docker containers, and one of them is a web server who has an internal address of 172.16.68.69. For all internal network requests I’m going to want that address returned for web.example.com. For external requests, web.example.com will get my wan IP address and use reverse proxy to get the web server.

The backup server has no idea about web.example.com even exists. But if it returns the wan ip, it won’t work inside the network.

I guess what I’m looking for is to somehow have the backup server provide the same results as the main server, especially if the main server goes down.

The term we need to understand better is 'host entries'.
Is that referring to /etc/hosts or some other file, and if the latter, does it constitute a list of hosts to be blocked, or a whitelist, or just host-to-ip address associations, or is it something you've configured Pi-hole for to use or something you've entered somewhere via Pi-hole's UI?

I’m running PiHole in a Docker container. This is part of my docker-compose.yaml

version: "3.3"
services:

  pihole:
    container_name: pihole
    domainname: docker
    hostname: ${PIHOLE_HOST}
    image: pihole/pihole:latest
    dns:
      - 127.0.0.1
      - 1.1.1.1
    ports:
      - 53:53/tcp
      - 53:53/udp
      - 80:80
      - 443:443
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    volumes:
      - ${USERDIR}/${REPODIR}/pihole/pihole:/etc/pihole
      - ${USERDIR}/${REPODIR}/pihole/dnsmasq.d:/etc/dnsmasq.d
      - ${USERDIR}/${REPODIR}/pihole/scripts:/etc/scripts
    environment:
      - VIRTUAL_PORT=80
      - TZ=${TZ}
      - WEBPASSWORD=${PIHOLE_PASSWORD}
      - DNS1=1.1.1.1
      - DNS2=1.0.0.1
    extra_hosts:
      - vpn.${DOMAINNAME}:${SERVER_IP}
      - pihole.${DOMAINNAME}:${SERVER_IP}
      - dmz:192.168.0.1

As you can see, I’m using the extra_hosts directive to add some dns entries to this pihole container.

As this is a Docker directive, your issue would be specific for Docker rather than Pi-hole.

I'd guess that as long as you start your containers with identical extra_hosts directives, your Docker containers should behave the same.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.