hassio-addons/addon-pi-hole

DNS queries of pi.hole return previous IP address #95

Sebazzz posted onGitHub

Problem/Motivation

I have migrated from a standalone pi-hole installation, to pi-hole in Home Assistant. My pi-hole is located at 192.168.0.2 (also happens to be Raspberry Pi 1, but that is not really relevant). My second raspberry pi I used to configure and setup Home Assistant including this add-on. After migration (transplanting SD cards) to my Raspberry Pi which used to run pi-hole (and therefore gets static IP 192.168.0.2 from DHCP), queries about pi.hole resolve to the previous IP of Home Assistant (which is now running on 192.168.0.2).

Expected behavior

nslookup of pi.hole should return current host IP

Actual behavior

nslookup returned previous host IP (of previous boot)

Steps to reproduce

  1. Have two raspberry pi (lets call it "A" and "B")
  2. Have "A" to be a static IP from DHCP
  3. Have "B" to be a dynamic IP from DHCP
  4. Install Home assistant and Pi-hole in B
  5. Change SD card to A or otherwise ensure that B gets a different IP from DHCP
  6. Do an nslookup to the IP assigned originally in step 2, you will find that nslookup of pi.hole points to the previous IP assigned in step 3.

Proposed changes

It seems something is cached, perhaps on add-on install.


:wave: Thanks for opening your first issue here! If you're reporting a :bug: bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be usefull.

posted by addons-assistant[bot] over 5 years ago

Can you post the output of your nslookup, the addon itself only adds loopback to the pi-hole name https://github.com/hassio-addons/addon-pi-hole/blob/2048cdb06fb047973de6564128033df67cd5dbfe/pi-hole/rootfs/etc/cont-init.d/pihole.sh#L184

I am guessing it is likely something pi-hole itself is doing in its config

Edit - also to add, what is your upstream DNS?

posted by sinclairpaul over 5 years ago

Output from nslookup (after I manually added 'pi.hole' as a host in the add-on config):

C:\>nslookup - 192.168.0.2
Default Server:  pi.hole
Address:  192.168.0.2

> pi.hole
Server:  pi.hole
Address:  192.168.0.2

Name:    pi.hole
Addresses:  192.168.0.2
          192.168.0.183

Otherwise the 192.168.0.2 would not be present in the output.

Upstream DNS is Google and Cloudflare, in addition to my router for the "local" domain.

posted by Sebazzz over 5 years ago

From further looking it may be from the entry in /data/pihole/setupVars.conf

Can you post an addon startup log with Debug set?

posted by sinclairpaul over 5 years ago

Home Assistant makes it a bit difficult to retrieve a full log, but what I got (by repeatedly executing hassio addon log) is attached. hassio-95.log

When I did an nslookup for pi.hole, this was logged:

dnsmasq: 31 192.168.0.156/63302 query[A] pi.hole.[redacted] from 192.168.0.156
dnsmasq: 31 192.168.0.156/63302 forwarded pi.hole.[redacted] to 1.0.0.1
dnsmasq: 31 192.168.0.156/63302 reply pi.hole.[redacted] is NXDOMAIN
dnsmasq: 32 192.168.0.156/63303 query[AAAA] pi.hole.[redacted] from 192.168.0.156
dnsmasq: 32 192.168.0.156/63303 forwarded pi.hole.[redacted] to 1.0.0.1
dnsmasq: 32 192.168.0.156/63303 reply pi.hole.[redacted] is NODATA-IPv6
dnsmasq: 33 192.168.0.156/63304 query[A] pi.hole from 192.168.0.156
dnsmasq: 33 192.168.0.156/63304 /etc/hosts.list pi.hole is 192.168.0.2
dnsmasq: 33 192.168.0.156/63304 /etc/pihole/local.list pi.hole is 192.168.0.183
dnsmasq: 34 192.168.0.156/63305 query[AAAA] pi.hole from 192.168.0.156
dnsmasq: 34 192.168.0.156/63305 forwarded pi.hole to 1.0.0.1
dnsmasq: 34 192.168.0.156/63305 reply pi.hole is NODATA-IPv6
posted by Sebazzz over 5 years ago

I actually meant the addon startup log itself, so I could see the config as it started, but this shows you the issue:

dnsmasq: 33 192.168.0.156/63304 /etc/hosts.list pi.hole is 192.168.0.2 dnsmasq: 33 192.168.0.156/63304 /etc/pihole/local.list pi.hole is 192.168.0.183

I am guessing that the .183 address is the one you do not want? I am going to guess Pi-hole sets this up itself when it first installs, this is symlinked across to the /data/pihole folder, so will not get overwritten. You should be able to manually fix the file, or backup, edit the file in the backup and restore.

posted by sinclairpaul over 5 years ago

How can I fix the file? Documentation how to actually get to a file within an add-on in hassio is very sparse. For instance, the data dir in /data when I log into SSH is almost empty.

posted by Sebazzz over 5 years ago

The easiest way would likely be install the Portainer addon (pay attention to the docs) which will give you access to the containers through the UI.

posted by sinclairpaul over 5 years ago

Thanks, that helped.

For anyone who might run into this issue:

  1. Install Portainer (ensure to switch the protection switch of the add-on off)
  2. Unhide the add-ons container from the portainer settings
  3. Open the interactive console, go to /data/pihole and edit local.list with vi.
  4. Restart add-on
posted by Sebazzz over 5 years ago

Just want to add on this, although not applicable in this case, uninstalling and reinstalling the add on would also resolve this issue.

posted by sinclairpaul over 5 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

posted by addons-assistant[bot] about 5 years ago

Fund this Issue

$0.00
Funded

Pull requests