Setup
I have a pi-hole (DNS and DHCP) on 192.168.1.1
I have a local device (hostname=server) with a static IP 192.168.1.10
I told pi-hole about server in the local DNS tab that it's IP is 192.168.1.10
I have a public registered wildcard domain *.example.com that resolves to 23.45.67.89
Expected Behaviour:
dig server.local.example.com @192.168.1.1 returns the local IP 192.168.1.10
This is already the case with devices that got their IP from pi-holes DHCP
Actual Behaviour:
dig server.local.example.com @192.168.1.1 returns the public wildcard-resolved IP for domain *.example.com : 23.45.67.89
Debug Token:
https://tricorder.pi-hole.net/vKHGWfKg/
Your debug log suggests that your configuration is very different from what you intend or expect it to be.
According to your debug log, your Pi-hole is hosted on a different address 192.168.2.10.
*** [ DIAGNOSING ]: Networking
[✓] IPv4 address(es) bound to the eth0 interface:
192.168.2.10/24
Your debug log does contain some local DNS records, but none of them points to 192.168.1.10.
-rw-r--r-- 1 root root 49 Feb 1 18:04 /etc/pihole/custom.list
192.168.2.240 homeassistant
192.168.2.15 raspi01
That command would send a DNS query to 192.168.1.1.
According to your debug log, that's your router/gateway, so Pi-hole wouldn't be involved at all:
*** [ DIAGNOSING ]: Networking
[i] Default IPv4 gateway: 192.168.2.1
* Pinging 192.168.2.1...
[✓] Gateway responded.
*** [ DIAGNOSING ]: Discovering active DHCP servers (takes 10 seconds)
Scanning all your interfaces for DHCP servers
* Received 338 bytes from eth0:192.168.2.10
Server IP address: 192.168.2.10
DHCP options:
Message type: DHCPOFFER (2)
dns-server: 192.168.2.10
router: 192.168.2.1
Hey, yes I "simplified" the IP and domain names in the OP, I did not know that I will add the debug log at that point.
with proper IP and domains:
Setup
I have a pi-hole (DNS and DHCP) on 192.168.2.10
I have a local device (hostname= raspi01 ) with a static IP 192.168.2.15
I told pi-hole about raspi01 in the local DNS tab that it's IP is 192.168.2.15
I have a public registered wildcard domain *.berchtold.live that resolves to 23.45.67.89
Expected Behaviour:
dig raspi01.local.berchtold.live @192.168.2.10 returns the local IP 192.168.2.15
This is already the case with devices that got their IP from pi-holes DHCP
Actual Behaviour:
dig raspi01.local.berchtold.live @192.168.2.10 returns the public wildcard-resolved IP for domain * .berchtold.live : 23.45.67.89
Each of raspi01 and raspi01.local.berchtold.live is a separate domain.
Unless .local.berchtold.live is your local search domain, DNS clients would have no way to arrive at the second when trying to resolve the first.
Your container running Pi-hole doesn't seem to be aware of this, but since you are using Pi-hole as DHCP server, I see you've correctly configured that as the local domain - but your configuration is currently missing an expand-hosts option.
Please see [SOLVED] How can I get the local domain name auto suffixed to hostnames in DHCP? - #2 by Bucking_Horn for ways to address this.
It is:
But this did the trick, thanks!
$ dig raspi01.local.berchtold.live @192.168.2.10 +short
192.168.2.15