dougbw / coredns_omada

CoreDNS plugin for TP-Link Omada SDN
Apache License 2.0
90 stars 9 forks source link

FR: use client hostname instead of name #18

Closed binzhou closed 1 year ago

binzhou commented 1 year ago

Thanks for creating this awesome plugin!

Just set it up and noticed that it used the "name" of the client instead of the "hostname" as the DNS name. Any reason for this? It was a bit counterintuitive as I would have expected to be able to resolve by client hostname.

Thanks again!

dougbw commented 1 year ago

Hi, when I was working in this I flipped between using the name/hostname a few times but settled on the name in the end.

The main reason was that I have various devices (printers, IoT, etc) which either do not report a hostname or report a long hostname which cannot be configured on the device. Using the name means I can easily set the client name in the Omada controller to something short.

When I was testing this, in most cases if a client reported a hostname than that would automatically be set as the name anyway but maybe this behaviour has changed in one of the updates.

I did write a small script to set the client names to match the hostname when possible, and started coding this functionality in to the Omada plugin but never developed it further.

binzhou commented 1 year ago

Ok I see. What I'm seeing at the moment is that a lot of my clients have names set to their mac address even when hostname is being reported.

Having said that, it's entirely possible my setup is the problem: I don't yet have a omada gateway installed (testing this dns solution out before I switch over) so Omada is NOT the source-of-truth for DHCP.

Given this was considered, happy to close this out - I can reopen if this still presents a problem after I get the gateway/router installed.

binzhou commented 1 year ago

Ok have omada router/gateway set up and acting as DHCP server. Still see the same behaviour - almost all my clients have a name generated based on mac address even when hostname is presented. My personal preference would be to use hostname if available and fall back to client name otherwise.

As a workaround, I've been manually updating a bunch of client names to match hostnames, but obviously this will fall out of sync if I change the hostname on the host.

dougbw commented 1 year ago

That does sound annoying - I have just tested connecting a new phone on to my network and the device name was automatically set to match the hostname without any issues.

Maybe it was due to it the controller initially seeing those devices before it the gateway/DHCP was managed?

binzhou commented 1 year ago

Ok - can confirm that new clients coming online now have client name set to hostname. So this seems to be a me problem due to not having a router added to the omada system before clients were first added.

dougbw commented 1 year ago

Glad you go lt workkng