This dig command shows that your Pi-hole knows a name for 192.168.1.10. If a similar lookup, forced through your UDM, returns the same, I'd say it works as expected.
Maybe your observation is just confused by mixing up some dig options? (click for more).
Reverse lookup of a hostname for a given IP address through a specific DNS server (e.g. your UDM at 192.168.1.1) requires -x option:
dig @192.168.1.1 -x <host-ip-address> +short
where +short will just give you the names.
Here, you used the right syntax to query Shanes-Desktop, yet a previous command shows DNS to know ShanesDesktop as a name (without a hyphen).
EDIT:
I know Ubiquiti's Edge Router family can be configured to make use of dnsmasq, mitigating update of local DNS records on device. I do not know about their Unifi product line.
Should your adopted dig commands reveal that indeed your UDM isn't returning local host records, you may want to check Ubiquiti 's support.
The script you linked above is fairly outdated and might not support newer devices. It doesn't look up hostnames by querying the controller but uses the controller API to get the desired information.
If you want to try out something, I would change the following:
With the upcoming pihole v5.0 one can create Local DNS records via the WEB GUI. The information is saved in /etc/pihole7custom.list. I would modify the script to write to that file instead of /etc/hosts. That has the advantage that you can see (and modify) the entries via WEB GUI also.
The script itself imports a unifi library (that's why you have to run sudo pip install unifi before). That pip is also outdated. But someone forked it and it is actively maintained. You could try to use the new forked version as a backend for the actual script.
Looks good, what the issue is relates to the fully qualified local domain.
The domain you use in Conditional Forwarding needs to be the data entered on the Unifi configuration. So if you have .lan as the Local domain name, then Unifi needs to be set for ShanesDesktop.lan. What is happening now is Pi-hole is asking for the hostname with the Local domain name added and Unifi doesn't know that.
I've adjusted the script to write to the custom.list file, but the default hosts output uses a tab delimeter rather than a space when it writes to the file, and pi-hole doesn't recognise it. If I manually edit the custom.list after import via the script and delete the tab and replace with a space, it shows in the pi-hole 5.0 UI fine.
Any chance the custom.list could treat a tab delimiter as a space and let it work? Or anyone have better python knowledge that can work out how to adjust the client-mapping.py file to copy the hosts as IP-space-Hostname rather than IP-tab-Hostname ?
I've got my local domain added from the Unifi config in the conditional forwarding field - I can see my desktop has the primary domain suffix showing correctly under network properties (Windows 10).
Doesn't seem to work though... the client-mapping script is working at the moment with /etc/hosts , although making it work with custom.list would be better!
This all could be an issue with my Unifi UDM - heaven knows it has it's issues right now.
Just wish I could work out how to make the script output from client-mapping.py insert a space between IP and Hostname instead of a TAB so it working in custom.list
Then I use the command:
sudo python /home/pi/client-mapping.py -f /etc/pihole/custom.list -c ControllerIP -u Username -p Password
All shows up in the Custom DNS section fine, and with the crontab updated to run this every 15 minutes if IP addresses change this gets updated dynamically.
Great you figured it out. I was going to suggest these exact same steps - but you were faster
It would be good if you could open an feature request here on discourse (or even a pull request on github about allowing pihole to import custom.list seperated with tabs. This might help others in the future.
There has to be only one line added
Glad it's working for you. I'm closing the feature request as it appears Unifi responds to dig requests so Conditional Forwarding is the proper approach.
I'm sure the folks that handle Unifi would be glad to fix that oversight.
Edit: If you can show us something from Unifi that says the behavior seen is intended and they don't have any plans to change it, then we can talk about patching Pi-hole to fix their broken implementation. As it is now we don't really know if that's what they intend to happen.
No problems. I’ve raised a support ticket and hope they respond.
I’m happy for this to be moved out of feature request and into general if that suits.
If possible though - could ignoring the tab delimiter change as per @yubiuser above be implemented? Then at least the input from the script (or any other possible ones like it in future) could work without changes.
Tab changes, probably not. Easier to change the script to output what Pi-hole expects. Think of it like an API, we have our specs and they work, the clients need to implement the agreement correctly.
One thing you could also do in your own fork: leave hosts.py untouched but loop over custom.list after it was written and str_replace all tabs by spaces.