multi coloured wooden mailbox mounted on door

Tips and Tricks: Bonjour .local and Unifi .localdomain

0

OK, now that I’ve gotten Unifi up and running, here are some more minor details that have taken me a while to get right. The first is how you can refer to devices in your local network with a nice text name rather than an IP address, there are two mechanisms for this using the .local and .localdomain names.

The net is that with Apple, Philips Hue, and Denon devices, you can refer to them as either richs-macbook-pro.local or richs-macbook.-pro.localdomain through two completely different mechanisms, a peer-to-peer mDNS and DHCP Hostnames to DNS Forwarder. It’s super confusing, but I finally get how it works. (See below for details)

Some devices don’t support Bonjour but do support DHCP Hostnames like Eve, Logitech Harmony Hub, Homebridge, Yeastar IP-PBX, Obihai ATA Adapters, and Facebook Portal

And some don’t support either like nVidia Shield, Christie Projectors, RainMachine so you need their real IP addresses to find them.

Use .local with Bonjour mDNS devices

The first is that one very convenient thing that many systems now do is use Bonjour, (aka Avahi, aka mDNS). This is a peer-to-peer system where you can advertise capabilities and it gives you a way to use friendly names instead of IP addresses on your internal network. Every device needs a client which is builtin with MacOS, and its part of iTunes for windows so download that and on Linux, it is called the Avahi client

As an example, Apple Macbooks, publish their file shares based on the “punctuation removed” and “spaces replaced by dashes” names from if you name your computer Rich's MacBook Pro then if you want to access shares on those devices, you type richs-macbook-pro.local

If you want to see all the local DNS names, then you can run the Discovery application that Lily Ballard has written, this displays all the Bonjour services running around on your network and can drill down on all of them. The most valuable thing is that it tells you the precise names that different things are using. It is split by protocols, so for instance all devices that are local advertising they have a webpage are in the _http._tcp which means HTTP running over TCP and you can click and see what’s available.

This is how the magic of Airplay works. Every device that can handle Airplay video and audio streams publishes what they can do under _airplay._tcp and this gives the location of all your HomePod minis.

Note that not all devices respect this use, although all Apple devices do.

Use with .localdomain Domain Name in DNS lookup based on DHCP client-hostname registration

However, the default of .local is a convention of Bonjour, but it does work differently.

With an Unifi Network setting at least for me it did, Unifi Networking has completely different parameters in your Controller > Network > Networks > LAN > Advanced > Domain Name which is obscurely described as “a domain name that can be used to access your network in the browser.

What this means is that there is a completely different mechanism to get local names that is based on DHCP reservations. When a client asks for an IP address from Unifi, it can provide a client-hostname and this gets pushed in the local DNS provider inside the Unifi Network. So what is happening is that the default DNS server is actually the UniFi controller and it adds these local names to the DNS database and then DNS forwards the rest to whatever you have it set with at the ISP level.

You can see the Client Identifier that comes with the DHCP request by looking at the Unifi Network > Client and then looking at the first Client Name field. This tells you the exact name that came to the system has, now not all of this works, so in experimenting, it works for Ubiquiti devices (that makes sense).

However not all devices will use the client-supplied Hostname, so this doesn’t work for things like RTI controllers, nVidia Shield, Eufy cameras being good examples.

YOu can see this on the property page of each client, look for the Hostname. The power nerds, this is called DHCP client option 12 which is the field number of the Hostname in the DHCP request from the client to the server. The server takes the hostname and pushes it into the UniFi DNS Forwarder so it is just for local users. There is as an aside a DHCP client option 15 which provides the rest of the domain name, but if that isn’t found, then Unifi Network uses the Default Name instead (which is set to .localdomain)

Note that Hostnames must be less than 64 characters and get truncated.

Also, some clients like the Belkin Soundform Connect and the Meross smart plugs send hostnames with spaces in them, like Soundform Connect. Or there are devices like Kaiterra that have invalid characters like a plus sign in the name. And in fact, it’s noted in AdGuard as a range behavior, so what seems to happen is that if the Hostname is invalid, then no DNS .localdomain is created.

For instance, the controller by default is at say 192.168.1.1, and when it registers that DNS address, it provides the client-hostname unifi so you can actually ping unifi.localdomain and you will get back 192.168.1.1.

As another example, Synology NAS will send their client-hostname as whatever you set, so if it synology then you can ping synology.localdomain and get access to this.

Note, that if you ping something that is not fully qualified, like “ping unifi”, then it will automatically add that .localdomain, so you really end up doing a “ping unifi.localdomain” and “ping synology” would work as well.

You can use the MacOS/Unix utility host to figure out what is in the system, so “host -a unifi” would give you the following return which basically says we asked for unifi.localdomain and we get. You can also use dig use do the same things

$ host unifi

Trying "unifi.localdomain"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63645
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;unifi.localdomain.		IN	ANY

;; ANSWER SECTION:
unifi.localdomain.	0	IN	A	10.0.1.1


$ dig google.com

;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43127
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		78	IN	A	142.251.33.78

;; Query time: 61 msec
;; SERVER: 10.0.1.1#53(10.0.1.1)
;; WHEN: Fri Aug 27 14:02:47 PDT 2021
;; MSG SIZE  rcvd: 55

Related Posts

This site uses Akismet to reduce spam. Learn how your comment data is processed.