Pihole container's hostname and router's hostname unknown to clients

Please follow the below template, it will help us to help you!

Expected Behaviour:

Pinging server by its hostname from the client works.
Pinging Pi-Hole by its hostname from the client and the server works.

Actual Behaviour:

Getting "unknown host" for both.

Debug Token:

97t9m2z2ye

I am running the pihole within a Docker container on my home router, which serves both DNS and DHCP. The router's host IP is 10.0.0.1.

This is how I created the container:
docker run -d --hostname pihole --name pihole -p 53:53/tcp -p 53:53/udp -p 10.0.0.1:67:67/udp -p 10.0.0.1:80:80 -p 10.0.0.1:443:443 -v /etc/pihole/:/etc/pihole/ -v /etc/dnsmasq.d/:/etc/dnsmasq.d/ -v /etc/dnsmasq.d-available/:/etc/dnsmasq.d-available/ -e ServerIP=10.0.0.1 --restart=unless-stopped --cap-add=NET_ADMIN --dns=127.0.0.1 --dns=1.1.1.1 pihole/pihole:latest

The ServerIP points to host IP, which according to various sources on the internet, is the right thing to do for the local LAN Pi-Hole setup.

However, it looks like Pi-Hole assumes the 10.0.0.1 is also its own IP address somehow. The /etc/hosts inside the container correctly maps pihole to 10.0.0.2 IP address:

root@pihole:/# cat /etc/hosts
127.0.0.1	localhost
10.0.0.2	pihole

However, the /etc/pihole/local.list is:

10.0.0.1 pihole
10.0.0.1 pi.hole

, which seems wrong to me.

nslookup results are even more confusing:

nslookup pi.hole                                                                                                                                   
Server:		10.0.0.2
Address:	10.0.0.2#53

Name:	pi.hole
Address: 10.0.0.1

, and:

nslookup pihole                                                                                                                          
Server:		10.0.0.2
Address:	10.0.0.2#53

Name:	pihole
Address: 10.0.0.1
Name:	pihole
Address: 10.0.0.2

As a result:

  1. I can't ping my router from my clients or from within the container by its hostname
  2. I can ping the Pi-Hole from my router by the pihole hostname, but not from my clients
  3. I can ping the Pi-Hole from my router and clients using the pi.hole hostname

PS. You may want to add to the Docker wiki instructions that mapping the /etc/dnsmasq.d-available/ may also be needed, given that it's not uncommon to have other packages (e.g. LXD) symlink the configs saved there to /etc/dnsmasq.d/

-e ServerIP=10.0.0.1 is what all your Pi-hole domains and ads are being set to. You should probably just be setting it to 0.0.0.0 to block ads without a block page, this is the new default pi-hole behavior. The docker readme suggesting your IP be passed in is old v3.0 cruft that needs to get updated to match 4.0's behavior.

The old default mode was show a block web page, which would require your ServerIP be returned for all ads and pi.hole. You can still do this if you tell Pi-hole to use that blocking mode - just make sure ServerIP is your external docker host IP (internal network, not internet IP), rather than the IP inside the container.

OK, so I switched it to use the container's own IP. I also added host's hostname to container via --add-hosts switch. I still can't ping host nor pihole from my clients.

The /etc/hosts inside the container has both references:

root@pihole:/# cat /etc/hosts
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
10.0.0.1	server
10.0.0.2	pihole

dnsmasq appears to be reading the entries:

root@pihole:/# cat /var/log/pihole.log |grep '/etc/hosts'
Nov 27 12:23:21 dnsmasq[333]: read /etc/hosts - 8 addresses
Nov 27 12:23:25 dnsmasq[500]: read /etc/hosts - 8 addresses

The local.list also contains the 'pihole' host:

root@pihole:/# cat /etc/pihole/local.list
10.0.0.2 pihole
10.0.0.2 pi.hole

Pinging "pi.hole" (with a dot) works fine.

I am out of ideas at this point. The only idea I have is that it's related to the "lan" domain name the presence of which is enforced by Pi-Hole.

EDIT: tried the "none" domain name which disables it completely, but that also didn't help.

Also tried this:

 cromo@Dawids-MacBookPro-41184 host 10.0.0.1                                                        
1.0.0.10.in-addr.arpa domain name pointer server.
 cromo@Dawids-MacBookPro-41184 host 10.0.0.2                                                              
2.0.0.10.in-addr.arpa domain name pointer pihole.

 cromo@Dawids-MacBookPro-41184 nslookup server      
Server:		10.0.0.2
Address:	10.0.0.2#53

Name:	server
Address: 10.0.0.1

So the DNS entries are returned as expected. I am totally puzzled.

EDIT: Turns out it was the DHCP's local domain name after all – I just forgot to reconnect the client.

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