Pi-Hole doesn't resolve DNS in the network, nslookup timed out

Expected Behaviour:

Pi Hole should work and block websites for all clients.

I am using it on a Raspberry Pi 4 Model B with Raspbian, docker and docker-compose connected over LAN to a Fritz!Box router. My docker-compose.yml looks as follows:

version: "3"

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    restart: unless-stopped
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      TZ: 'Europe/Berlin'
      WEBPASSWORD: 'mypassword'
      DNS1: 9.9.9.9
      ServerIp: 192.168.178.50
    volumes:
       - '/opt/containers/pihole/pihole/:/etc/pihole/'
       - '/opt/containers/pihole/dnsmasq/:/etc/dnsmasq.d/'
    dns:
      - 127.0.0.1
      - 9.9.9.9
    cap_add:
      - NET_ADMIN

Tried it with IPv6 disabled and enabled. It is a fresh installation (of Raspbian and Docker).

I add the Pi-Hole IP address to my routers DNS settings (with another alternative DNS server).

In the Pi-Hole settings, I checked "Listen on all interfaces".

Actual Behaviour:

The DNS server doesn't work in the network, Pi-Hole can't resolve the URLs into IPs from any client in the same network.

The dashbord looks as follows:

It looks like Pi-Hole works only on the localhost machine. If I add the IP address of the Pi-Hole Raspberry server manually on a client in the same network, I can't load any website.
From a client, nslookup europa.eu 192.168.178.50 returns:
;; connection timed out; no servers could be reached

But ping 192.168.178.50 works fine and as you can see I can visit the admin dashboard as well.

On the same client, nslookup europa.eu 9.9.9.9 as well as using the router with nslookup europa.eu 192.168.178.1 (because it uses the alternative DNS server instead of Pi-Hole).

The result of sudo netstat -anlp | grep -w LISTEN is:

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      509/sshd            
tcp6       0      0 :::80                   :::*                    LISTEN      18662/docker-proxy  
tcp6       0      0 :::53                   :::*                    LISTEN      18690/docker-proxy  
tcp6       0      0 :::22                   :::*                    LISTEN      509/sshd            
tcp6       0      0 :::443                  :::*                    LISTEN      18648/docker-proxy  

Debug Token:

https://tricorder.pi-hole.net/zo6sje32dj

Clear the browser cache and reload the page.

Thanks, that solved removing the Dashboard-loading problem but the main DNS problem still exists. :confused:

This maybe an issue of correctly configuring Docker's network driver.

Also, your use of ServerIP (note the capital P) seems uncommon, since it is strictly required only when running in Docker's host mode, but in that mode, you wouldn't need any explicit port mappings (see also Running Pi-hole Docker).

I changed it into ServerIP and add the network_mode: "host". Now, nslookup works on the client (for example nslookup europa.eu 192.168.178.50). The wired thing: Adding the DNS server in the router doesn't work: It can't resolve the DNS records. :confused:

After a lot of trial & error I solved the problem, also without the network_mode: "host" option.

My resulting docker-compose.yml file looks as follows:

version: "3"

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    restart: unless-stopped
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      TZ: 'Europe/Berlin'
      WEBPASSWORD: 'mypassword'
      DNS1: 9.9.9.9
    volumes:
       - '/opt/containers/pihole/pihole/:/etc/pihole/'
       - '/opt/containers/pihole/dnsmasq/:/etc/dnsmasq.d/'
    dns:
      - 127.0.0.1
      - 9.9.9.9

Also, there are some problems with the Pi-Hole DNS config Listen on all interfaces. Selecting Listen only on interface eth0 works.

Furthermore, I set the Raspberry Pi IP in the router (Fritz!Box) several times ago as the primary DNS server. Applying the config again now triggers the router to use the first, primary DNS (I think the router routes the hole traffic to the secondary DNS server due to a long inactivity of the Pi-Hole).

But with all this, it works! :slight_smile: