From my other posts, you will probably gather I am “Mr. Low Level”, I like to get access as close to the metal as possible.
So it shouldn’t surprise you that most of my setup is static IP. That means static ips actually flashed into device firmware. So a SOnOff switch might have 10.0.0.9 hardcoded into it and the server address of 10.0.0.3 is also hard coded into the networking calls.
But… I now have about a dozen devices in my eco system and that is expected to grow. I’m starting to dislike static hardcoded addressing.
My first thoughts where of course DNS which would allow most network requests be to a “named entity” rather than an IP. So for example, I would send an ON command to a SOnOff called living-room-lights-1.mydomain.com rather than 10.0.0.12
While this provides flexibility in containing all the name->IP mappings in one place where it can be edited, it does not help me if I want to move that switch off 10.0.0.12 and put it somewhere else.
So, DHCP will of course allow me to assign IPs to MACs in a single place.
What I need is a way to combine the two. DNSMasq provides this functionality. However I stumbled upon “PiHole” which comes as a RaspberryPI image, a normal installer or as a Docker image. Not only does it provide DNSMasq functionality, it also has large lists of advertisement servers and aims to block DNS requests to these.
I have not yet tried, but I believe with DHCP the host asking for a lease can provide it’s hostname, the DHCP server can choose to ignore this and assign it one, but either way it can post a DNS record update to the DNS server for that host and IP. So now it would be the one DHCP config file (or webUI) where you can say:
aa:bb:cc:xx:xx:xx:xx:xx -> 10.0.0.12 -> living-room-lights-1.
So I can freely move that device to a different IP and/or host name without even having to touch it, just maybe power cycle it.
There are caveats of course. You can only really have one DHCP server per subnet or it gets confusing. You “can” technically have more than one if they are working together in HA or if one is master and the others are configured to relay to the master. The later (DHCP Proxy/Relay) is also how you get DHCP (a broadcast protocol) to transit a router between subnets. Most good Wifi routers provide this functionality out of the box, but software solutions exist too.
I’m curious as to what others have done in this regard.