I've recently set up a Pi Zero W with the as-of-writing most recent Pi OS Lite image. It is connected to my home network via Ethernet and has Pi-hole installed on it. I found that during setup and, more noticeably while making DNS queries to it, I would occasionally see "hangs" where my SSH terminal would stop responding to input, or DNS queries would take longer than normal generally without seeing any noticeable spike in CPU/memory usage, after which the connection would return to normal.
For instance, if I run the following
# using pi zero as DNS server, time fetching A records for wikipedia.org 50x
$ for i in {1..50}; do
> /usr/bin/time -f 'real %e' dig @pizero.local +noall +answer wikipedia.org
> done
wikipedia.org. 320 IN A 198.35.26.96
real 0.03
wikipedia.org. 320 IN A 198.35.26.96
real 0.01
wikipedia.org. 320 IN A 198.35.26.96
real 0.02
...
I would see ~45 responses in 0.01s or 0.02s real time, but the other 5 would instead be 5.01s or 5.02s durations.
Initially, I suspected the default 100MiB configured swap space might be the culprit, but removing the swap did not improve this behavior. I've not installed any other services, and was experiencing this behavior prior to installing Pi-hole while editing files with vim
or doing other activities requiring interactive input. What could be causing this?
options timeout:2
to/etc/resolv.conf
and do thedig
-loop again. If the delays are now 2 seconds in stead of 5 seconds, the problem is in the name resolution. That may be a client-side problem or the nameserver being unavailable. But then it is not cpu or memory problems directly.ssh
is yielding:ssh: connect to host pizero.local port 22: No route to host
sudo /etc/init.d/networking restart
has no effect; the same outcome occurs.