I have a strange issue with hostname resolution. I'm running the latest beta version of Pi-hole and I have a Unifi Dream Machine as my router also acting as my DHCP.
It seems Pi-hole is resolving hostnames in a way that I don't understand. On my old router and Pi-hole 4.4 I used the etc/hosts file to get hostnames to show right. With my UDM I was able to get conditional forwarding working. I have 2 networks on my router that I have pointing to the Pi-hole. On the UDM I have given these domain names of home and iot. I added these to the Custom DNS/Local Host Names list in Pi-hole 5.o and everything seemed to be working fine. I have a few devices that have actual hostnames that don't help me much so I added these to my etc/hosts file with better hostnames.
Now things get weird. I decided to rename my domains on my router to home.local and iot.local. I also changed the Custom DNS/Local Host Names to reflect this. I did this and restarted DNS on my Pi-hole but it wasn't recognizing the new domain names. I even restarted the Pi-hole but no dice. I then decide to comment out one of the entries in etc/hosts to see what happens and nothing changed on the Pi-hole. It still used the friendly hostname I gave it in the etc/hosts file. It seems Pi-hole is pulling that name from somewhere that I don't know about. I even removed the entries from Custom DNS/Local Host Names and it's still getting hostnames from somewhere.
I'm attaching some screenshots:
That query log shows a hostname that doesn't exist in the etc/hosts file