Not able to resolve DNS for only a couple minutes per day

Expected Behaviour:

To be working as expected.

Actual Behaviour:

Sometimes pi.hole would unable to resolve DNS for my devices on my network. It is only intermittent for a couple minutes at a time, about once a day occurance (or less).

I also am seeing the following in the logs:
WARNING in dnsmasq core: not giving name raspberrypi to the DHCP lease of 10.0.0.156 because the name exists in /etc/hosts with address 127.0.1.1
I currently have a static IP assigned for:

  • 10.0.0.155 -> raspberrypi-eth0
  • 10.0.0.156 -> raspberrypi-wlan0
    The raspberrypi is the device that currently hosts the pihole service. I have connected the pi via both ethernet and wifi.

Debug Token:

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

If your /etc/hosts file has the entry 127.0.1.1, that is incorrect, it should be 127.0.0.1, and the host name should be localhost. Not saying this is specifically causing your issue, but sure does not appear to be correct.

I believe that 127.0.1.1 is used as an alias for hostname and is different from lo / 127.0.0.1 though I don't think its used much or generally needed.

I think the issue is running both interfaces. What is the purpose of connecting the pi via wifi and ethernet?

I would like to use wifi as a fallback if eth is giving trouble.

Have you used it like this before your issue occurred? Its not generally recommeded to have both on. I would suggest turning it off for a period of time and see if your issue stops. At the very least you will eliminate this as the cause.

127.0.1.1 is not the issue.
Both my Debian and Raspbian/Pi-OS systems have that line:

$ cat /etc/hostname
hak01
$ cat /etc/hosts
127.0.0.1    localhost
127.0.1.1    hak01.home.dehakkelaar.nl  hak01
[..]
$ hostname -i
127.0.1.1
$ nc -vz 127.0.0.1 22
localhost [127.0.0.1] 22 (ssh) open
$ nc -vz 127.0.1.1 22
hak01.home.dehakkelaar.nl [127.0.1.1] 22 (ssh) open

The issue is that the wlan0 interface is still configured to acquiring an IP via DHCP.
If configure this wlan0 interface manually with a static IP, or disable Wifi/the wlan0 interface, the WARNING will be gone.

Have you tried disconnecting both one at a time to see whats happening?
Have you considered what will happen with the default route (notice the eth0 interface below)?

$ ip route list default
default via 10.0.0.1 dev eth0

Bonding the two physical interfaces to create a virtual bond interface with a single IP and default route is a nice solution:

Do mind though that above link is only an example for older Debian/Raspbian releases!
Current releases can come with some sort of network mangler (network-manager, dhcpcd5, systemd-networkd, connman etc) so you need to figure out how to do bonding with them.

How did you do that?
Are you positive that you've manually configured those on device?

Your debug log as well as the warning you've quoted would suggest that your OS would still try to renew DHCP leases, at least for your wlan0 interface.

While you should fix that, it is unlikely that it would contribute to your resolution failures.

When that happens again, please share the output of:

nslookup pi.hole
nslookup discourse.pi-hole.net
nslookup discourse.pi-hole.net 10.0.0.155
nslookup discourse.pi-hole.net 10.0.0.156

That's nothing to worry about.
Debian based distros would create a 127.0.1.1 hostname entry by default, as a workaround for some software misbehaving otherwise, see Debian docs on hostname resolution.

Thank you for the debug commands, I will keep them handy. Do I run them from my laptop, or from within the raspberrypi? Thank you everyone as well for your thoughts as well.

You are correct that it looks like I have forgotten to specify wlan0 interface to be made static. While they were configured static on the netgear orbi router and within the pi.hole dhcp web interface, wlan0 was not configured as such within /etc/dhcpcd.conf on the pi.
I have updated the contents of the /etc/dhcpcd.conf file to include both interfaces now.

interface eth0
        static ip_address=10.0.0.155/24
        static routers=10.0.0.1
        static domain_name_servers=1.1.1.1 1.0.0.1

interface wlan0
        static ip_address=10.0.0.156/24
        static routers=10.0.0.1
        static domain_name_servers=1.1.1.1 1.0.0.1

And to clarify regarding to my netgear orbi router setting, I set them as static routes for the pi's mac addresses, but the setting "Use Router as DHCP Server" was disabled. So I do not think it would have any impact anyways.
Here is a new debug link for reference: https://tricorder.pi-hole.net/CxlDfIAT/ This is produced immediately after applying the dhcpcd.conf file changes and rebooting the pi.
These are the only diagnosis logs at this time:

DHCP packet received on wlan0 which has no address
DHCP packet received on eth0 which has no address
not using configured address 10.0.0.155 because it is in use by the server or relay
not using configured address 10.0.0.156 because it is in use by the server or relay

Thank you for the explanation, I learned something new.

Sounds like the interfaces are still not configured with static IP's.
You could run below one to see if a static IP is assigned to a particular interface:

sudo dhcpcd --test

Eg:

$ sudo dhcpcd --test
[..]
eth0: using static address 10.0.0.4/24

Whats output for below two?

hostnamectl | grep Operating

apt policy dhcpcd5 network-manager

Here are the outputs of the commands sudo dhcpcd --test:

DUID 00:01:xxx
eth0: IAID 01:xxx
eth0: using static address 10.0.0.155/24
interface='eth0'
pid='12389'
protocol='dhcp'
reason='TEST'
ifcarrier='up'
ifflags='4163'
ifmtu='1500'
ifwireless='0'
new_broadcast_address='10.0.0.255'
new_domain_name_servers='1.1.1.1 1.0.0.1'
new_ip_address='10.0.0.155'
new_network_number='10.0.0.0'
new_routers='10.0.0.1'
new_subnet_cidr='24'
new_subnet_mask='255.255.255.0'
dhcpcd exited

hostnamectl | grep Operating:
Operating System: Raspbian GNU/Linux 11 (bullseye)

apt policy dhcpcd5 network-manager:

dhcpcd5:
  Installed: 1:8.1.2-1+rpt5
  Candidate: 1:8.1.2-1+rpt9
  Version table:
     1:8.1.2-1+rpt9 500
        500 http://archive.raspberrypi.org/debian bullseye/main armhf Packages
 *** 1:8.1.2-1+rpt5 100
        100 /var/lib/dpkg/status
     7.1.0-2 500
        500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages
network-manager:
  Installed: (none)
  Candidate: 1.30.6-1+deb11u1
  Version table:
     1.30.6-1+deb11u1 500
        500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages

For eth0, it seems to be configured correctly for a static one.
But for wlan0, the details seems to be somehow missing from the output .

For comparison, below an arcade Pi thats connected via Wifi only and acquiring an IP via DHCP (not a static one):

$ sudo dhcpcd --test
eth0: waiting for carrier
DUID 00:01:00:xxx
wlan0: IAID f6:xxx
wlan0: rebinding lease of 10.0.0.219
wlan0: soliciting an IPv6 router
wlan0: leased 10.0.0.219 for 86400 seconds
interface='wlan0'
pid='25612'
protocol='dhcp'
reason='TEST'
ifcarrier='up'
ifflags='4163'
ifmtu='1500'
ifssid='hak_wifi'
ifwireless='1'
new_broadcast_address='10.0.0.255'
new_dhcp_lease_time='86400'
new_dhcp_message_type='5'
new_dhcp_rebinding_time='75600'
new_dhcp_renewal_time='43200'
new_dhcp_server_identifier='10.0.0.2'
new_domain_name='home.dehakkelaar.nl'
new_domain_name_servers='10.0.0.2 10.0.0.4'
new_host_name='arcade02'
new_ip_address='10.0.0.219'
new_network_number='10.0.0.0'
new_routers='10.0.0.1'
new_subnet_cidr='24'
new_subnet_mask='255.255.255.0'
old_broadcast_address='10.0.0.255'
old_dhcp_lease_time='86400'
old_dhcp_message_type='5'
old_dhcp_rebinding_time='72495'
old_dhcp_renewal_time='40095'
old_dhcp_server_identifier='10.0.0.2'
old_domain_name='home.dehakkelaar.nl'
old_domain_name_servers='10.0.0.2 10.0.0.4'
old_host_name='arcade02'
old_ip_address='10.0.0.219'
old_network_number='10.0.0.0'
old_routers='10.0.0.1'
old_subnet_cidr='24'
old_subnet_mask='255.255.255.0'
dhcpcd exited

From above, did you disable Wifi somehow?

I did not disable wifi, I am still able to access the pihole web via both 10.0.0.155 and 10.0.0.156. If I force the test on wlan0, this is the output for sudo dhcpcd --test wlan0:

DUID 00:01:xxx
wlan0: IAID 01:xxx
wlan0: using static address 10.0.0.156/24
interface='wlan0'
pid='12736'
protocol='dhcp'
reason='TEST'
ifcarrier='up'
ifflags='4163'
ifmtu='1500'
ifssid='Wi-Fi Network'
ifwireless='1'
new_broadcast_address='10.0.0.255'
new_domain_name_servers='1.1.1.1 1.0.0.1'
new_ip_address='10.0.0.156'
new_network_number='10.0.0.0'
new_routers='10.0.0.1'
new_subnet_cidr='24'
new_subnet_mask='255.255.255.0'
dhcpcd exited

That looks all good.
Do you get new below messages after rebooting (I cant see a date/time stamp)?

Yes, they are visible in the web interface

I still think having Pi-hole doing DHCP for your LAN and being connected with two interfaces to the same network segment doesnt work well together.
I can imagine a client broadcasting a DHCPDISCOVER and Pi-hole receiving them twice via both interfaces.
I think bonding/teaming those two interfaces like described earlier will solve above and your issues warnings.

I did a quick search on the net for how to do bonding in combination with dhcpcd5 but there isnt much.
The bond interface configuration is still mostly done via ifupdown:

$ man ifup
[..]
DESCRIPTION
       The ifup and ifdown commands may be used  to  configure  (or,
       respectively, deconfigure) network interfaces based on inter‐
       face definitions in the  file  /etc/network/interfaces.
$ systemctl cat networking.service
# /lib/systemd/system/networking.service
[Unit]
Description=Raise network interfaces
Documentation=man:interfaces(5)
[..]
ExecStart=/sbin/ifup -a --read-environment
$ systemctl is-active networking.service
active

And assigning its IP through dhcpcd5 ... which is a bit of a mess.

If confident enough, you could decide to disable dhcpcd entirely (removing a dependency).
And configure everything through ifupdown with the help of below example:

Except that you want the bond0 interface to have a static IP instead of a DHCP one.
You could alter that segment like below:

# Define master
auto bond0
iface bond0 inet static
    address 10.0.0.155
    netmask 255.255.255.0
    broadcast 10.0.0.255
    gateway 10.0.0.1
    bond-slaves none
    bond-primary eth0
    bond-mode active-backup
    bond-miimon 100

EDIT: Dont forget the install in the introduction:

$ apt policy ifenslave
ifenslave:
  Installed: (none)
  Candidate: 2.9
  Version table:
     2.9 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages

EDIT2: Oh and you most likely need to exclude the eth0 & wlan0 interfaces from DHCP with below dnsmasq directive (one line for each interface):

$ man dnsmasq
[..]
       -2, --no-dhcp-interface=<interface name>
              Do not provide DHCP or TFTP on the specified interface,
              but do provide DNS service.

Eg:

$ sudo nano /etc/dnsmasq.d/99-my-settings.conf
no-dhcp-interface=eth0
no-dhcp-interface=wlan0

And also run below one to reconfigure the main interface into that of the bond0 interface:

pihole -r

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