Local DNS records not resolving

I have several local DNS records configured and Pi-hole v6 is forwarding them to the router instead of answering from cache. The router doesn't know the answer so the host is unable to resolve. Pi-hole v5 answers from cache and works as expected.

For example:

v6:

dig pihole

; <<>> DiG 9.10.6 <<>> pihole
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64095
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;pihole.				IN	A

;; Query time: 41 msec
;; SERVER: 192.168.10.25#53(192.168.10.25)
;; WHEN: Sat Nov 25 16:45:03 PST 2023
;; MSG SIZE  rcvd: 35

v5:

dig pihole @192.168.10.20

; <<>> DiG 9.10.6 <<>> pihole @192.168.10.20
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10889
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;pihole.				IN	A

;; ANSWER SECTION:
pihole.			60	IN	A	192.168.10.25

;; Query time: 44 msec
;; SERVER: 192.168.10.20#53(192.168.10.20)
;; WHEN: Sat Nov 25 16:45:53 PST 2023
;; MSG SIZE  rcvd: 51

debug token: https://tricorder.pi-hole.net/rs9HosuQ/

I have three questions for you:

  1. Is the entry included in /etc/pihole/hosts/custom.list ?

  2. What happens in /var/log/pihole/pihole.log when you manually add a new line in this file?
    (I know the headers says don't do this)

  3. What happens in /var/log/pihole/pihole.log when you run

    dig pihole
    

    again on your v6 Pi-hole?

  1. The file is empty.
pi@pi0-2:/etc/pihole/hosts$ ls -l
total 0
-rw-rw---- 1 pihole pihole 0 Nov 17 05:33 custom.list
  1. Nov 26 06:49:10 dnsmasq[329594]: read /etc/pihole/hosts/custom.list - 1 names

  2. Works as expected.

Nov 26 06:53:16 dnsmasq[329594]: query[A] pihole from 192.168.10.159
Nov 26 06:53:16 dnsmasq[329594]: /etc/pihole/hosts/custom.list pihole is 192.168.10.25

EDIT:
I have another custom.list file in /etc/pihole and it contains all my local DNS records that show up in the web interface.

Okay, so the file was empty and is not any longer and everything is working as expected now? If so, we have to add a small change to ensure this file is definitely written. The other file you have seen is the old location but it had to move into a dedicated directory, seems there might be a glitch causing the new for to be empty initially

Only the hostname I manually put into the file is working. I think I'll try copying the custom.list file into the new location and see what happens.

EDIT:
After copying the file over, everything is working as expected.

Please try the following just for me to see what we need to do for the weirdest audience:

  1. make the file empty again
  2. Add another hostname you have never had before (e.g. sometest123.com with any IP)
  3. Check if the file is now populated with all the expected lines plus the just added one
  4. Remove this testing domain again
  5. Check if the file is still containing everything expected and the test domain is gone

I made the file empty and added a domain through the Local DNS records page in the web interface.

The custom.list file was still empty in /etc/pihole/hosts and the file in /etc/pihole was unchanged.

It appeared to update correctly in the web interface so I checked to see what file actually got changed. It looks like it wrote a new line to the pihole.toml file instead of the custom.list file.

It should write to both, the toml file should always have everything and can be used to regenerate everything else if needed. I'll try to reproduce why the custom.list is not written when work and family duties allow :slight_smile:

Thanks for all your input so far!

My pleasure. Please let me know if there's something else I can try for you.

I just realized that my CNAME records weren't migrated over when I did the v5 to v6 upgrade. At least they're not in the web interface or pihole.toml file.

Possibly same bug?

I tried to reproduce this and actually failed. Everything is working as expected for me on development-v6.

Please run

pihole-FTL --config debug.config true

and try again the test as described above. What does /var/log/pihole/FTL.log say to your changes?

Also: When did you do this? Is there any chance we can still have a look on the rotated logs at that time in /var/log/pihole/FTL.log.* ?

Here's the FTL log when I tried adding a test domain via the web interface with an empty file in /etc/pihole/hosts/

2023-11-26 14:38:31.461 [631991/F594854] DEBUG_ANY: Reopening Gravity database for this fork
2023-11-26 14:40:52.631 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.14 -> /etc/pihole/config_backups/pihole.toml.15
2023-11-26 14:40:52.632 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.13 -> /etc/pihole/config_backups/pihole.toml.14
2023-11-26 14:40:52.633 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.12 -> /etc/pihole/config_backups/pihole.toml.13
2023-11-26 14:40:52.633 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.11 -> /etc/pihole/config_backups/pihole.toml.12
2023-11-26 14:40:52.634 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.10 -> /etc/pihole/config_backups/pihole.toml.11
2023-11-26 14:40:52.635 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.9 -> /etc/pihole/config_backups/pihole.toml.10
2023-11-26 14:40:52.636 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.8 -> /etc/pihole/config_backups/pihole.toml.9
2023-11-26 14:40:52.636 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.7 -> /etc/pihole/config_backups/pihole.toml.8
2023-11-26 14:40:52.637 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.6 -> /etc/pihole/config_backups/pihole.toml.7
2023-11-26 14:40:52.638 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.5 -> /etc/pihole/config_backups/pihole.toml.6
2023-11-26 14:40:52.639 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.4 -> /etc/pihole/config_backups/pihole.toml.5
2023-11-26 14:40:52.639 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.3 -> /etc/pihole/config_backups/pihole.toml.4
2023-11-26 14:40:52.640 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.2 -> /etc/pihole/config_backups/pihole.toml.3
2023-11-26 14:40:52.642 [594854/T631662] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.1 -> /etc/pihole/config_backups/pihole.toml.2
2023-11-26 14:40:52.643 [594854/T631662] DEBUG_CONFIG: Copying /etc/pihole/pihole.toml -> /etc/pihole/config_backups/pihole.toml.1
2023-11-26 14:40:52.646 [594854/T631662] DEBUG_CONFIG: Copied /etc/pihole/pihole.toml -> /etc/pihole/config_backups/pihole.toml.1
2023-11-26 14:40:52.647 [594854/T631662] INFO: Config file written to /etc/pihole/pihole.toml
2023-11-26 14:40:52.648 [594854/T631662] DEBUG_CONFIG: Opening /etc/pihole/custom.list.tmp for writing
2023-11-26 14:40:52.649 [594854/T631662] DEBUG_CONFIG: custom.list unchanged

I upgraded to v6 beta soon after it was announced. My FTL logs only go back to 11/24/23. :frowning:

:thinking:

Please run

pihole checkout ftl fix/files_different

(the pre-built binaries should be read in about 20-30 minutes from now) and repeat the test. I added more verbose logging when files are compared and fixed a small glitch where files with a different number of lines may have been considered identical.

https://github.com/pi-hole/FTL/pull/1785

Using that branch worked. It seems to have fixed them problem and the custom.list file is being written to now.

2023-11-27 05:37:13.750 [776051/T776263] DEBUG_CONFIG: Files /etc/pihole/pihole.toml.tmp and /etc/pihole/pihole.toml differ at line 118
2023-11-27 05:37:13.751 [776051/T776263] DEBUG_CONFIG: -> /etc/pihole/pihole.toml.tmp:118 = '    "192.168.10.25 pihole",'
2023-11-27 05:37:13.751 [776051/T776263] DEBUG_CONFIG: -> /etc/pihole/pihole.toml:118 = '    "192.168.10.25 pihole"'
2023-11-27 05:37:13.760 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.14 -> /etc/pihole/config_backups/pihole.toml.15
2023-11-27 05:37:13.760 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.13 -> /etc/pihole/config_backups/pihole.toml.14
2023-11-27 05:37:13.761 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.12 -> /etc/pihole/config_backups/pihole.toml.13
2023-11-27 05:37:13.762 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.11 -> /etc/pihole/config_backups/pihole.toml.12
2023-11-27 05:37:13.762 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.10 -> /etc/pihole/config_backups/pihole.toml.11
2023-11-27 05:37:13.763 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.9 -> /etc/pihole/config_backups/pihole.toml.10
2023-11-27 05:37:13.764 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.8 -> /etc/pihole/config_backups/pihole.toml.9
2023-11-27 05:37:13.764 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.7 -> /etc/pihole/config_backups/pihole.toml.8
2023-11-27 05:37:13.765 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.6 -> /etc/pihole/config_backups/pihole.toml.7
2023-11-27 05:37:13.766 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.5 -> /etc/pihole/config_backups/pihole.toml.6
2023-11-27 05:37:13.766 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.4 -> /etc/pihole/config_backups/pihole.toml.5
2023-11-27 05:37:13.767 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.3 -> /etc/pihole/config_backups/pihole.toml.4
2023-11-27 05:37:13.768 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.2 -> /etc/pihole/config_backups/pihole.toml.3
2023-11-27 05:37:13.768 [776051/T776263] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.1 -> /etc/pihole/config_backups/pihole.toml.2
2023-11-27 05:37:13.769 [776051/T776263] DEBUG_CONFIG: Copying /etc/pihole/pihole.toml -> /etc/pihole/config_backups/pihole.toml.1
2023-11-27 05:37:13.770 [776051/T776263] DEBUG_CONFIG: Copied /etc/pihole/pihole.toml -> /etc/pihole/config_backups/pihole.toml.1
2023-11-27 05:37:13.771 [776051/T776263] INFO: Config file written to /etc/pihole/pihole.toml
2023-11-27 05:37:13.773 [776051/T776263] DEBUG_CONFIG: Opening /etc/pihole/custom.list.tmp for writing
2023-11-27 05:37:13.774 [776051/T776263] DEBUG_CONFIG: Files /etc/pihole/custom.list.tmp and /etc/pihole/hosts/custom.list differ at the final line 0
2023-11-27 05:37:13.774 [776051/T776263] DEBUG_CONFIG: -> /etc/pihole/custom.list.tmp:0 = '# Pi-hole: A black hole for Internet advertisements
'
2023-11-27 05:37:13.774 [776051/T776263] DEBUG_CONFIG: -> /etc/pihole/hosts/custom.list:0 = '<EOF>'
2023-11-27 05:37:13.775 [776051/T776263] DEBUG_CONFIG: HOSTS file written to /etc/pihole/hosts/custom.list
2023-11-27 05:38:14.522 [778043/F776051] DEBUG_ANY: Reopening Gravity database for this fork
2023-11-27 05:39:39.264 [776051/T776262] DEBUG_CONFIG: Files /etc/pihole/pihole.toml.tmp and /etc/pihole/pihole.toml differ at line 118
2023-11-27 05:39:39.264 [776051/T776262] DEBUG_CONFIG: -> /etc/pihole/pihole.toml.tmp:118 = '    "192.168.10.25 pihole"'
2023-11-27 05:39:39.265 [776051/T776262] DEBUG_CONFIG: -> /etc/pihole/pihole.toml:118 = '    "192.168.10.25 pihole",'
2023-11-27 05:39:39.281 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.14 -> /etc/pihole/config_backups/pihole.toml.15
2023-11-27 05:39:39.282 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.13 -> /etc/pihole/config_backups/pihole.toml.14
2023-11-27 05:39:39.283 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.12 -> /etc/pihole/config_backups/pihole.toml.13
2023-11-27 05:39:39.284 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.11 -> /etc/pihole/config_backups/pihole.toml.12
2023-11-27 05:39:39.284 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.10 -> /etc/pihole/config_backups/pihole.toml.11
2023-11-27 05:39:39.285 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.9 -> /etc/pihole/config_backups/pihole.toml.10
2023-11-27 05:39:39.286 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.8 -> /etc/pihole/config_backups/pihole.toml.9
2023-11-27 05:39:39.287 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.7 -> /etc/pihole/config_backups/pihole.toml.8
2023-11-27 05:39:39.288 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.6 -> /etc/pihole/config_backups/pihole.toml.7
2023-11-27 05:39:39.289 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.5 -> /etc/pihole/config_backups/pihole.toml.6
2023-11-27 05:39:39.290 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.4 -> /etc/pihole/config_backups/pihole.toml.5
2023-11-27 05:39:39.291 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.3 -> /etc/pihole/config_backups/pihole.toml.4
2023-11-27 05:39:39.291 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.2 -> /etc/pihole/config_backups/pihole.toml.3
2023-11-27 05:39:39.292 [776051/T776262] DEBUG_CONFIG: Rotated /etc/pihole/config_backups/pihole.toml.1 -> /etc/pihole/config_backups/pihole.toml.2
2023-11-27 05:39:39.293 [776051/T776262] DEBUG_CONFIG: Copying /etc/pihole/pihole.toml -> /etc/pihole/config_backups/pihole.toml.1
2023-11-27 05:39:39.294 [776051/T776262] DEBUG_CONFIG: Copied /etc/pihole/pihole.toml -> /etc/pihole/config_backups/pihole.toml.1
2023-11-27 05:39:39.296 [776051/T776262] INFO: Config file written to /etc/pihole/pihole.toml
2023-11-27 05:39:39.297 [776051/T776262] DEBUG_CONFIG: Opening /etc/pihole/custom.list.tmp for writing
2023-11-27 05:39:39.298 [776051/T776262] DEBUG_CONFIG: Files /etc/pihole/custom.list.tmp and /etc/pihole/hosts/custom.list differ at line 42
2023-11-27 05:39:39.299 [776051/T776262] DEBUG_CONFIG: -> /etc/pihole/custom.list.tmp:42 = ''
2023-11-27 05:39:39.299 [776051/T776262] DEBUG_CONFIG: -> /etc/pihole/hosts/custom.list:42 = '192.168.10.2 test'
2023-11-27 05:39:39.300 [776051/T776262] DEBUG_CONFIG: HOSTS file written to /etc/pihole/hosts/custom.list
1 Like

This is the key line, thanks. It shows that our fix helped as the current development-v6 code does not detect if one of the files we compare here is completely empty.

I marked the bugfix ready for review + merge. It'll land in development-v6 as soon as one of our team members can find the time to review and test my fix for themselves.

Please make sure you run

pihole checkout ftl development-v6

at some point when this is merged as the custom branch you are on right now will not receive any future updates.

1 Like

Here it doesnt work either and i'm not sure what to do despite this thread marked as solved

i have one host configured in webui

This appears in the config as well:

[...]
  # Array of custom DNS records
  # Example: hosts = [ "127.0.0.1 mylocal", "192.168.0.1 therouter" ]
  #
  # Possible values are:
  #     Array of custom DNS records each one in HOSTS form: "IP HOSTNAME"
  hosts = [
    "192.168.2.1 fritz.box"
  ] ### CHANGED, default = []
[...]

Still, pihole refuses to resolve that

The entry is present in costum.list as well, but this file represents an old state, on webui i've got one one entry, in this all 20+ entries i recently deleted are still present,

What branch are you on?

The fix may currently still require to checkout fix/files_different until that's merged into development-v6:

ah, i see. So either wait or change to that.

i think i'll wait. ^^
Thanks for your fast response

If you change the branch, you can test if the fix also works for you. If there is another reason why it's not working for you, we can react quickly and tweak the fix even before it lands in development-v6 . In addition, further testing by users also tends to speed up the review process. Do you need any further arguments? :slight_smile: