Pihole and vlan no hostname

Expected Behaviour:

See Hostname of the client

Actual Behaviour:

Hi, I have the pihole in a docker on a mikrotik. It works to work, except that I can't get the hostname of the devices.
Before making two VLANs everything worked. Now I put the pihole in its own network 192.168.55.xx and I have two vlans 192.168.240.1 and 192.168.0.1

I have the checkbox:

-Respond only on interface eth0
-Never forward non-FQDN A and AAAA queries
-Never forward reverse lookups for private IP ranges
-Use DNSSEC
-Use Conditional Forwarding (with parameters of 192.168.0.1)

I created a file /etc/dnsmasq.d/03-vlans.conf

rev-server=192.168.240.0/24,192.168.240.1 server=/domus/192.168.240.1

But I don't get any hostname, what am I doing wrong?

if I dig @192.168.0.1 192.168.0.xx +short
an empty line answers me

Thank you

Debug Token:

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

In general, note that inter-VLAN communication is managed by your router.

Your dig result suggests that 192.168.0.1 does not know how to reverse lookup an IP (or you've used an IP where indeed no hostname is known for).

Your debug log suggests three networks:
192.168.0.0, 192.168.55.0 and 192.168.240.0.
Your Pi-hole resides in the 55.0 subnet.

What's the result of

dig <hostname> @router-ip

for each of your routers, and a known hostname from each subnet?

Thanks for the reply.
Here is the output of what you asked me, the only note that in the 192.168.55.0 network there is only the pihole, so I had to dig from the pihole.

Thanks again for the time you are giving me


PC-Surface IP: 192.168.0.xxx

dig PC-Surface @192.168.0.1

; <<>> DiG 9.16.45 <<>> PC-Surface @192.168.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 3864
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

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

;; Query time: 4 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Sat Feb 10 22:19:31 ora solare Europa occidentale 2024
;; MSG SIZE  rcvd: 39

Alexa-View-Studio IP: 192.168.240.xxx

dig Alexa-View-Studio @192.168.240.1

; <<>> DiG 9.16.45 <<>> Alexa-View-Studio @192.168.240.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 2535
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;Alexa-View-Studio.             IN      A

;; Query time: 4 msec
;; SERVER: 192.168.240.1#53(192.168.240.1)
;; WHEN: Sat Feb 10 22:48:34 ora solare Europa occidentale 2024
;; MSG SIZE  rcvd: 46

pihole IP: 192.168.55.xxx

I'm not sure about the pihole hostname, because I use a script to create static DNS in mikrotik and in the 192.168.55.0 network I didn't put that script

dig pi.hole @192.168.55.1

; <<>> DiG 9.16.44-Debian <<>> pi.hole @192.168.55.1
;; global options: +cmd
;; connection timed out; no servers could be reached

Your router replies with NXDOMAIN, i.e. it does not know local hostnames.

Some routers may allow you to script their DHCP servers to register hostnames as presented during DHCP lease negotiation in their own DNS server, or switching DHCP server to dnsmasq, which does that automatically.

Alternatively, you could consider creating relevant respective DNS records directly in Pi-hole.

Thanks, but I don't understand why before creating the VLANs and I had the pihole and devices in a single network everything worked...

I use this script in Mikrotik to create static DNS and I haven't changed it:

# When "1" all DNS entries with IP address of DHCP lease are removed
:local dnsRemoveAllByIp "1"
# When "1" all DNS entries with hostname of DHCP lease are removed
:local dnsRemoveAllByName "1"
# When "1" addition and removal of DNS entries is always done also for non-FQDN hostname
:local dnsAlwaysNonfqdn "1"
# DNS domain to add after DHCP client hostname
:local dnsDomain "lan"
# DNS TTL to set for DNS entries
:local dnsTtl "00:15:00"
# Source of DHCP client hostname, can be "lease-hostname" or any other lease attribute, like "host-name" or "comment"
:local leaseClientHostnameSource "comment"

:local leaseComment "dhcp-lease-script_$leaseServerName_$leaseClientHostnameSource"
:local leaseClientHostname
:if ($leaseClientHostnameSource = "lease-hostname") do={
  :set leaseClientHostname $"lease-hostname"
} else={
  :set leaseClientHostname ([:pick \
    [/ip dhcp-server lease print as-value where server="$leaseServerName" address="$leaseActIP" mac-address="$leaseActMAC"] \
    0]->"$leaseClientHostnameSource")
}
:local leaseClientHostnameShort "$leaseClientHostname"
:local leaseClientHostnames "$leaseClientHostname"
:if ([:len [$dnsDomain]] > 0) do={
  :set leaseClientHostname "$leaseClientHostname.$dnsDomain"
  :if ($dnsAlwaysNonfqdn = "1") do={
    :set leaseClientHostnames "$leaseClientHostname,$leaseClientHostnameShort"
  }
}
:if ($dnsRemoveAllByIp = "1") do={
  /ip dns static remove [/ip dns static find comment="$leaseComment" and address="$leaseActIP"]
}
:foreach h in=[:toarray value="$leaseClientHostnames"] do={
  :if ($dnsRemoveAllByName = "1") do={
    /ip dns static remove [/ip dns static find comment="$leaseComment" and name="$h"]
  }
  /ip dns static remove [/ip dns static find comment="$leaseComment" and address="$leaseActIP" and name="$h"]
  :if ($leaseBound = "1") do={
    :delay 1
    /ip dns static add comment="$leaseComment" address="$leaseActIP" name="$h" ttl="$dnsTtl"
  }
}

this is the script of the 192.168.0.0 network
I use the same script on the 192.168.240.0 network with dnsDomain lan changed to dnsDomain domus

That would be out of Pi-hole's scope, so I can only try a guess:
If the scripts themselves would be operational, the most obvious explanation would be that those scripts never get triggered.

If you can, try to verify if that's the case.

SOLVED:

In Mikrotik with this setup you need to enable DNS -> Allow Remote Requests

1 Like

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