leigh
leigh
former enthusiast.
Apr 1, 2020 3 min read

Hostnames With Unifi Networks

thumbnail for this post

For what has seemed like months I’d been plagued with rogue hostnames hitting my network devices and I’d struggled to track it down…until today.

I was putting together a really hacky solution to a weird problem ages ago and set a hostname on a Raspberry Pi to be its IP address concatenated with the device name. Something like “1-2-3-4-MyDevice”. This hacky solution turned out to have more pitfalls that the problem that it was supposed to be solving, so I binned it, set the hostname back to something sensible and went about my business.

However, I found that the hacky hostname I’d been using kept popping back up all the time.

No amount of searching around hostname setting was yielding any workable results and I was so tired of purging ARP tables and using Wireshark to track down who on earth is sending out this spurious nonsense across my network that I eventually gave up.

I’d decided that it had to be either the PiHole (it’s always DNS!) or the Unifi USG running as the DHCP server, but all of the interfaces were showing that my hostnames were as I wanted them, and the spurious entries were only there in the logs to taunt me.

Fast forward to today and for the second time running my Mac was picking up a hostname that belonged to some kid up the road’s Android tablet. He hadn’t been to our house to play with the girls for ages so what fresh hell was this?

I’d recently had network issues that had caused me to have to reboot a lot of the network kit over the course of about a day and so during this all of the dhcp leases had expired and when I finally got things back it was a race for the good IPs again.

Enough was enough. I could pretend that the indignity of my network not playing by my rules wasn’t true when it was an obscure device I wasn’t logged onto daily, but to infect my primary machine with this nonsense? That I could not let pass.

So I started the search where I left off and finally found out that the culprit was some bug in the Unifi USG 3 / dhcp implementation.

In the Unifi portal everything was still showing as fine, but given that pretty much everything else reported in the Unifi portal is wildly inaccurate I decided I’d log on to the USG itself and see what was happening.

And there it was, plain as day.

Editing the /etc/hosts file on the USG (the dhcp server) furnished me with a list of scores of entries for network devices old and new. My spurious IP-address-name? Check. My recently usurped Mac name? Check. Multiple entries per IP address and seemingly they were given out at random - so one day my Mac would pick up its real hostname (that was in there too) and another day it would pick up the kid’s Android device’s hostname because he’d used that address once.

Grrr.

A quick clean out of that list and there are no more gremlins in my network for the time being.

comments powered by Disqus