Conditional Forwarding not working

Expected Behaviour:

I have set up Conditional Forwarding on my brand new Pi-Hole, I know the settings are correct, but local hostnames are not resolved by Pi-Hole.

Router: Ubiquiti ERPoE5
Pi-Hole installed on a RPi4 2 GB RAM, requests are blocked, everything seems in order except local hostnames being resolved.

Conditional Forwarding setup:

Local Network: 192.168.2.0/24
DHCP Server IP: 192.168.2.1
No local domain name.

Actual Behaviour:

Pi-Hole Dashboard / Top Clients shows IP addresses instead of hostnames.

Debug Token:

https://tricorder.pi-hole.net/r24j3c99o1

What does a dig for an expected IP address return?

dig -x <IPADDRESS> @192.168.2.1

war4peace@PIHOLE:~ $ dig -x 192.168.2.88 @192.168.2.1

; <<>> DiG 9.11.5-P4-5.1+deb10u5-Raspbian <<>> -x 192.168.2.88 @192.168.2.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 61925
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 54f573f8fb21d729ccd15ccf6092d58a05ff3e9f2e3c6595 (good)
;; QUESTION SECTION:
;88.2.168.192.in-addr.arpa.     IN      PTR

;; AUTHORITY SECTION:
168.192.in-addr.arpa.   900     IN      SOA     ns1.rdsnet.ro. dns-adm.rdsnet.ro. 2003060200 10800 3600 360000 86400

;; Query time: 3 msec
;; SERVER: 192.168.2.1#53(192.168.2.1)
;; WHEN: Wed May 05 18:27:38 BST 2021
;; MSG SIZE  rcvd: 139

The DNS server at 192.168.2.1 doesn't know the answer and that's why you're not seeing the hostname instead of an IP address.

That's my router. When logging in to it, it shows all local IPs and hostnames.
From other machines, I could input the hostname directly, for example my Unraid server has a hostname of "Tower" and I can go to the browser from another machine and type in "Tower" and it would take me to the server's webpage.

Here's a screenshot from the router's DHCP (some hostnames have been obfuscated intentionally):

The router at 192.168.2.1 (the only one, actually) does know the answer - but maybe there's something I need to configure on it, specifically for Pi-Hole?

Maybe. That dig command is essentially what we do for finding the hostname to IP mapping. As you displayed, there is no response from 192.168.2.1 that provides any information. A proper response would be something like:

dan@Viking-1:~$ dig -x 192.168.88.5 @192.168.88.2

; <<>> DiG 9.11.5-P4-5.1+deb10u3-Debian <<>> -x 192.168.88.5 @192.168.88.2
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18967
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;5.88.168.192.in-addr.arpa.     IN      PTR

;; ANSWER SECTION:
5.88.168.192.in-addr.arpa. 1    IN      PTR     ubuntu.lan.

;; Query time: 2 msec
;; SERVER: 192.168.88.2#53(192.168.88.2)
;; WHEN: Wed May 05 10:16:57 PDT 2021
;; MSG SIZE  rcvd: 78

Where your problem may also lie is in the fact that your Pi-hole IP address is not what you have set the DHCP server to use.

IPV4_ADDRESS=192.168.2.11/24

*** [ DIAGNOSING ]: Name resolution (IPv4) using a random blocked domain and a known ad-serving domain
[✓] www.ellads.com is 0.0.0.0 via localhost (127.0.0.1)
[✗] Failed to resolve www.ellads.com via Pi-hole (192.168.2.11)
[✓] doubleclick.com is 142.250.185.110 via a remote, public DNS server (8.8.8.8)

*** [ DIAGNOSING ]: Discovering active DHCP servers (takes 10 seconds)
   Scanning all your interfaces for DHCP servers
   Timeout: 10 seconds
   
   * Received 300 bytes from eth0:192.168.2.1
     Offered IP address: 192.168.2.12
     Server IP address: N/A
     Relay-agent IP address: N/A
     BOOTP server: (empty)
     BOOTP file: (empty)
     DHCP options:
      Message type: DHCPOFFER (2)
      server-identifier: 192.168.2.1
      lease-time: 86400 ( 1d )
      netmask: 255.255.255.0
      router: 192.168.2.1
      dns-server: 192.168.2.12
      renewal-time: 43200 ( 12h )
      rebinding-time: 75600 ( 21h )
      --- end of options ---
    
   DHCP packets received on interface eth0: 1
   DHCP packets received on interface wlan0: 0
   DHCP packets received on interface lo: 0

I think I know what happened. I have first set up Pi-hole with Wireless enabled, then connected it to wired, and now they are both enabled. I think they are fighting each other :slight_smile:
I can connect to pi-hole using both .11 and .12 local addresses.

Update: I have disabled wireless connection from the pi-hole, do I have to do something else to get rid of the leftover .11 local address? Rebooting pi-hole did not help in making local hostnames work.

To fix the .11 to .12 you should run pihole -r and reconfigure to the intended IP address.

I don't think that will solve the hostname issue as that still won't return an PTR record from 192.168.2.1 which is currently returning NXDOMAIN responses.

Hmmm, I have run pihole -r and that IP address confusion is resolved. And you are correct, local hostnames are still not resolved.
Output below:

war4peace@PIHOLE:~ $ dig -x 192.168.2.10 @192.168.2.1

; <<>> DiG 9.11.5-P4-5.1+deb10u5-Raspbian <<>> -x 192.168.2.10 @192.168.2.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 12514
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;10.2.168.192.in-addr.arpa.     IN      PTR

;; Query time: 1 msec
;; SERVER: 192.168.2.1#53(192.168.2.1)
;; WHEN: Wed May 05 19:13:14 BST 2021
;; MSG SIZE  rcvd: 54

Seeing that you are using Ubiquiti routing equipment, this likely fails due to lack of appropriate DNS record creation on DHCP lease registration, i.e. your router cannot answer the corresponding DNS requests (just as demonstrated by you executing Dan's earlier dig command).

Some Ubiquiti models would be able to mitigate this by switching the on-device DHCP server to dnsmasq .
You'd have to consult with Ubiquiti support whether your router would support that and how to enable it.

In case that's not possible, you can still create Local DNS records for your IP addresses in Pi-hole.
Obviously, this will only be a viable option if your devices are assigned with a fixed IP address.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.