Sudden intermittent DNS problems

Expected Behaviour:

On Sunday I completed a new Pihole installation and everything seemed to be working just fine.

Actual Behaviour:

I get back today on Friday and suddenly Pihole can't resolve any DNS's. I have been troubleshooting for hours with no luck and really need to get my family back on the internet.

Debug Token:

ca3pgo9305

I have performed a repair to pihole. Also oddly, my dashboard indicates it is blocking 9 domains when it should be more like 800,000. Also, the cpu on my pi never drops below 25% and pihole is the only thing I have installed on the Pi.

Standard checks.
Check if dnsmasq is "running":

pi@noads:~ $ sudo service dnsmasq status -l
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled)
  Drop-In: /run/systemd/generator/dnsmasq.service.d
           └─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
   Active: active (running) since Thu 2018-03-15 18:43:07 CET; 3 months 8 days ago
  Process: 27814 ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf (code=exited, status=0/SUCCESS)
  Process: 27881 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
  Process: 27876 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
  Process: 27873 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
 Main PID: 27880 (dnsmasq)
   CGroup: /system.slice/dnsmasq.service
           └─27880 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpk...

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

Check if dnsmasq is resolving and using the lists (with 10.0.0.2 being my Pi-hole):

pi@noads:~ $ nslookup pi.hole localhost
Server:         localhost
Address:        ::1#53

Name:   pi.hole
Address: 10.0.0.2

Check connectivity and name resolution on a client PC (can be Linux, Windows or Mac):

C:\>nslookup pi.hole 10.0.0.2
Server:  noads.dehakkelaar.nl
Address:  10.0.0.2

Name:    pi.hole
Address:  10.0.0.2

Check if clients are configured with the correct DNS server (should be only one DNS server):
For most Linux distro's including MacOS:

pi@arcade:~ $ cat /etc/resolv.conf
# Generated by resolvconf
domain dehakkelaar.nl
nameserver 10.0.0.2

For Windows PC's check the DNS section (again, only one DNS server should be configured):

C:\>ipconfig /all

Windows IP Configuration

Ethernet adapter Local Area Connection:

   IPv4 Address. . . . . . . . . . . : 10.0.0.11(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : zaterdag 23 juni 2018 11:47:29
   Lease Expires . . . . . . . . . . : zondag 24 juni 2018 11:47:29
   Default Gateway . . . . . . . . . : 10.0.0.1
   DHCP Server . . . . . . . . . . . : 10.0.0.2
   DNS Servers . . . . . . . . . . . : 10.0.0.2

Most if the checks are ok. The only ones that seem to not work are:

Check connectivity and name resolution on a client PC (can be Linux, Windows or Mac):

C:\>nslookup pi.hole 192.168.0.139
        Server:  raspberrypi
        Address:  192.168.0.139

DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** Request to raspberrypi timed out.

Check if clients are configured with the correct DNS server (should be only one DNS server):
For most Linux distro’s including MacOS:

pi@raspberrypi:~ $ cat /etc/resolv.conf
# Generated by resolvconf
domain lan
nameserver 127.0.0.1

I noticed your name server was the address of your pi, so I changed mine likewise. Now instead of looking like yours, the address changed from ::1#53 to 127.0.0.1#53. Any idea why that is?

Now here is some strangeness. I ran the nslookup on my pc again and it timed out once, then said

DNS request timed out.
timeout was 2 seconds.
Server: UnKnown
Address: 192.168.0.139

DNS request timed out.
timeout was 2 seconds.
Name: pi.hole
Address: 192.168.0.139

Why is server UnKnown now and why did it time out once before responding?

I ran nslookup again and it times out twice and gave the same unknown server and address as directly above. I ran it a third time and it timed out all 4 times.

I ran it a few more times and the behavior was erratic. Sometimes it would respond that the server and address were raspberrypi and 192.168.0.139 respectively (and correctly) but still timed out 3 or 4 times. Regardless it is strange and inconsistent.

Another note, I ran "top" on the Pi and it showed that dnsmasq was using nearly 100% %CPU. This seems to jive with the 25% constantly shown in on the Pi desktop graph (1 of 4 CPU's is constantly near 100%). Is this normal? I would think not. It could also explain why DNS times out at times and doesn't at others.

You were suppose to run that one on a Linux or Mac client PC, not on the Pi-hole host.
As the "raspberrypi" host is already running its own DNS server (dnsmasq), its configured to query its own localhost interface IP address for DNS lookups.
For ipv4 this is "127.0.0.1".
For ipv6 this is "::1".
Dnsmasq is configured to listen to both the ipv4 and ipv6 addresses so it doesnt really matter if you configure the ip4 or the ip6 address.
And "/etc/resolv.conf" is populated by the "resolveconf" process, as mentioned in the same file, chances are at next reboot, it reverted back to "::1".

Tail the logs to see whats keeping dnsmasq so busy:

pihole -t

[i] Default IPv4 gateway: 192.168.0.2
192.168.0.2
   * Pinging 192.168.0.2
192.168.0.2...
[βœ—] Gateway did not respond. (https://discourse.pi-hole.net/t/why-is-a-default-gateway-important-for-pi-hole/3546)

Is this the correct gateway? Reconfigure with pihole -r if not.

[βœ—] Failed to resolve www.appleidonline.info via Pi-hole (192.168.0.139)

The Pi-hole couldn't connect to its own IP address. This possibly indicates a larger network issue.

Some of the blocked domains start with -, which is an invalid way to start a domain. Check your block lists and remove the lists with the invalid domains.

I tried poking around and nothing was working, though everything seemed correct. I disabled DHCP on Pihole and switched back to DHCP on my router and everything immediately worked again. I'm back to blocking ads and everything is back to normal.

1 Like

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