Local DNS resolves as 0.0.0.0 for itself

I upgraded to v6 recently and after fixing the problems I am left with 1 annoyance which I cannot solve. I use pihole local DNS to access my few servers.
They are added via web Local DNS records:

server1.lan 192.168.1.2
server2.lan 192.168.1.3

The problem is, the pihole is running on server2 and pihole returns address for this query as 0.0.0.0, see the example:

#nslookup server2.lan
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   server2.lan
Address: 0.0.0.0

I think this is because hostname is set also to server2 so it return own host address (0.0.0.0). The problem is, if I do command from server1:
ssh server2.lan
it tries to connect to itself (server1) cause it resolves server2 as 0.0.0.0.

How can I fix this or is there a workaround?

1 Like

How did that nslookup register in Pi-hole's Query Log?

sudo grep server2.lan /var/log/pihole/pihole.log

Feb 26 10:35:43 dnsmasq[58]: query[A] server2.lan from 192.168.1.8
Feb 26 10:35:43 dnsmasq[58]: Pi-hole hostname server2.lan is 0.0.0.0

Please upload a debug log and post just the token URL that is generated after the log is uploaded by running the following command from the Pi-hole host terminal:

pihole -d

or if you run your Pi-hole as a Docker container:

docker exec -it <pihole-container-name-or-id> pihole -d

where you substitute <pihole-container-name-or-id> as required.

debug log - https://tricorder.pi-hole.net/b2UfrjzO/

notes about real dns names.
pihole runs on hostname "rp3" with IP 192.168.1.3
the 0.0.0.0 is returned for rp3.lan

Your debug log shows that you run your Pi-hole as a Docker container.

Your local DNS record definitions look ok:

     hosts = [
       (…+6 names…)
       "192.168.1.3 rp3",
       "192.168.1.3 rp3.lan"
     ] ### CHANGED, default = []

But even though pihole-FTL/dnsmasq reads the resulting definitions from custom.list during startup, it is replying with 0.0.0.0:

   Feb 26 08:52:09 dnsmasq[58]: using only locally-known addresses for lan
   Feb 26 08:52:09 dnsmasq[58]: read /etc/hosts - 8 names
   Feb 26 08:52:09 dnsmasq[58]: read /etc/pihole/hosts/custom.list - 8 names
   Feb 26 08:52:13 dnsmasq[58]: query[A] rp3.lan from 192.168.1.8
   Feb 26 08:52:13 dnsmasq[58]: Pi-hole hostname rp3.lan is 0.0.0.0

Run from your Pi-hole machine, what's the output of

docker exec -it <pihole-name-or-id> cat /etc/hosts

where you substitute <pihole-name-or-id> with your Pi-hole container's name or id (as listed e.g. by docker ps).

Yes, its docker.

rp3:~$ docker exec -it pihole cat /etc/hosts

# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#

127.0.1.1 rp3 rp3
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Watching this closely as I experience the same issue. I think I'd help if nsswitch were preferring dns over files, as my Pihole is using DHCP and I configured it to forward requests to my router.

So the own hostname in /etc/hosts is 127.0.1.1 (which is very common) and Pihole prefers (nsswitch) files over dns, so if I lookup Pihole's FQDN i get 127.0.0.1. (Lucky the pi.hole lookup returns the real IP).

Noteable difference to OP: I've an empty custom.list

For me even pi.hole lookup returns zeroes.

$ nslookup pi.hole
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   pi.hole
Address: 0.0.0.0

interestingly, if I choose different name as hostname and add that one for 192.168.1.3, it returns correctly:

$ nslookup cubieboard2.lan
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   cubieboard2.lan
Address: 192.168.1.3

Pi-hole is DNS exclusively, it does not concern itself with nsswitch at all, but it reads /etc/hosts.

Are you running your Pi-hole as a container, MostFrabjous?


Juraj_jiv, I tried to recreate your issue by editing /etc/hosts in a Pi-hole v6 container, but my domains still resolve.

Your 0.0.0.0 answer could indicate that Pi-hole would block the domain, but putting pi.holeon a blocklist still wouldn't trigger you condition.

However, it made me remember that while ago we had issues in some v5 container's returning 0.0.0.0 for pi.hole.

Please share your docker compose or docker run script used to start your Pi-hole container.

So nss is out of the picture. Good to know.

I'm running pihole in a container too. I'm forwarding requests from my local LAN to my router whichs also serving DHCP and DNS. The queries for all the hosts on my network get forwarded to my router and work well, but pihole's FQDN (pi.beeb.at) gets resolved to 127.0.0.1. wipi is a cname

Lookups

pi.hole

# lookup
NAME    	TYPE	CLASS	TTL	ADDRESS 	NAMESERVER 	TIME TAKEN 
pi.hole.	A   	IN   	0s 	10.0.0.2	10.0.0.2:53	5ms       	

# log
00:32:25: query[A] pi.hole from 10.0.1.1
00:39:05: Pi-hole hostname pi.hole is 10.0.0.2

pi.beeb.at (FQDN via DHCP)

# lookup
NAME       	TYPE	CLASS	TTL	ADDRESS  	NAMESERVER 	TIME TAKEN 
pi.beeb.at.	A   	IN   	0s 	127.0.1.1	10.0.0.2:53	5ms       	

# log
00:37:40: query[A] pi.beeb.at from 10.0.1.1
00:37:40: /etc/hosts pi.beeb.at is 127.0.1.1

Config

docker run

sudo podman run -d \
    -p 80:80 \
    -p 53:53/tcp \
    -p 53:53/udp \
    -v pihole:/etc/pihole \
    -v dnsmasq:/etc/dnsmasq.d \
    -e TZ=Europe/Vienna \
    -e WEBPASSWORD=REDACTED \
    -e FTLCONF_local_ipv4=10.0.0.2 \
    -e DNSMASQ_LISTENING=all \
    --restart=unless-stopped \
    --name=pihole \
    pihole/pihole

pihole -d

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

hosts

Inside container

27.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
127.0.1.1	pi wipi
10.88.0.1	host.containers.internal
10.88.0.24	1ef2dd547223 pihole

Host

127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters

127.0.1.1	pi wipi

This variable is invalid.

Did you mean FTLCONF_dns_reply_host_IPv4?

Also, why are you using this specific IP?

My start script for docker:

$ cat run.sh 
docker run -itd \
--name=pihole \
--restart=always \
--net=host \
-v /opt/pihole/etc-pihole:/etc/pihole \
-v /opt/etc-dnsmasq.d:/etc/dnsmasq.d \
-e TZ=Europe/Bratislava \
pihole/pihole:latest

This line is a leftover from testing. I should have removed that. But as the line is invalid, it's not impacting our issue. 10.0.0.2 is Pi-hole's ip, that it gets from DHCP

Per @rdwebdesign 's suggestion, have you tried the FTLCONF_dns_reply_host_IPv4 environment variable?

Yes, now I had time to test:

Another option - regarding to this thread - is to run macvtap: How to change broadcasted DNS IP address in DHCP (v6) - #2 by niaw

[EDIT: Made a mistake and thought the proper IP was returned during testing, but it wasn't, so NOK]

I did full clean start and it works there. I have no idea why.
I added my 5 custom list and 6 local hostnames and replaced with old docker. So it works now. If someone wants to investigate I can zip old and new etc-pihole folder for investigation.

I'd like to diff them!

I had what I think is the same problem: my pihole is set to resolve unknown domains from my router, and the router is configured to provide IP addresses various .lan hostnames. However after upgrading, the pihole was successfully resolving the IP form the router (as seen in the logs), but then replying with "0.0.0.0" to all requests.

I found the expert setting DNS > DNS domain settings > Pi-hole domain name, which was set to "lan". I cleared this, and the problem was resolved.

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