I have pihole v5.1.1 and I've added some hosts that I don't want to be pushed to the upstream DNS servers. My pihole should resolve queries for two different local domains: .lan1 and .lan2. When I try to resolve something like comp1.lan1 or comp2.lan2, the queries are pushed to the public DNS servers.
I've made sure that "custom.list" is in the "/etc/dnsmasq.d/01-pihole.conf". When I put the hosts mentioned above in "/etc/hosts", they get resolved normally but they also get pushed to the upstream DNS servers.
I just added "no-hosts" to "/etc/dnsmasq.d/01-pihole.conf" and then restarted the Pihole FTL. It started to consult the "custom.list" file. I removed the "no-hosts" and then restarted the FTL again and it kept working. Strange.
About forwarding the local queries to the upstream DNS servers, actually, only the AAAA queries are being pushed. Is there any way to disable the AAAA queries for certain domains or entirely without disabling IPV6 for the client?
Never forward non-FQDNs may not apply here, as comp1.lan1 already contains a dot.
Assuming that you are using your router as DHCP server, you should be able to divert DNS queries for hosts in your local lan1 and lan2 domains by providing a custom configuration file, e.g. /etc/pihole/50-local-domains.conf:
server=/lan1/192.168.0.x
server=/lan2/192.168.0.x
Replace 192.168.0.x with your router's IP address.
If you want to limit resolution strictly to local definitions on your Pi-hole only, use instead:
local=/lan1/
local=/lan2/
Note that you have to supply hostnames manually for anylan1 and lan2 device with this configuration.