News for hackers. Stuff that matters.
Re:Show HN: An etcd backed DHCP server by lclarkmichalek on Monday July 17, 2017 @05:46PM (#14792539)
I wanted to set up some home automation based on my phone connecting to wifi, but parsing dhcpd's lease file didn't seem cloud native enough, so I implemented this. Surprisingly, it actually works, is concurrency safe (you can legitimately run two of them on the same network, and you'll not corrupt the etcd state. I mean, I pity the clients that have to deal with that network, but eh), and um, is almost useful.

I would not recommend anyone use this for anything other than entertainment.

Re:Show HN: An etcd backed DHCP server by selvakn on Monday July 17, 2017 @10:21PM (#14793878)
If it is for executing some script on successful connection of any device to wifi (and thus an IP is assigned), with dhcpd, it can be achieved with the following config:

  subnet 192.168.1.0 netmask 255.255.255.0 {
    on commit {
      set ip = binary-to-ascii (10, 8, ".", leased-address);
     execute ("/usr/local/bin/on-device-connect", "commit", ip);
    }
  }
I have setup exactly this to automate stuff unlocking the door in my office (in the morning, whenever some one arrives and phone connects to wifi).

My original source: http://jpmens.net/2011/07/06/execute-a-script-when-isc-dhcp-...

Edit: Fix code formatting.

Re:Show HN: An etcd backed DHCP server by lclarkmichalek on Tuesday July 18, 2017 @02:39AM (#14794664)
Ah but that's not cloud native at all!

More seriously, part of the reason I did the project was to see if I could have things react to the dhcp server, and not have the dhcpserver run things for me. No good reason, other than wanting all the components in my home network to run in their own VMs, and so having everything talking via etcd is convenient.

That said, if I didn't have copious amounts of free time, I definitely should have done that.

Re:Show HN: An etcd backed DHCP server by TeMPOraL on Tuesday July 18, 2017 @05:56AM (#14795382)
What does "cloud native" mean? Microservices in containers?
Re:Show HN: An etcd backed DHCP server by _e on Tuesday July 18, 2017 @12:16AM (#14794231)
Can you share more information on how your setup physically unlocks the door? Does it involve an electric strike or a motor that turns a lock?
Re:Show HN: An etcd backed DHCP server by selvakn on Tuesday July 18, 2017 @03:04AM (#14794763)
Sure.

This is the lock that Im using: http://www.ebay.com/itm/12V-Electromagnetic-Door-Locks-Magne... . Its electromagnetic and not a turn lock.

And the actuator that I built to control the lock is something like this: https://www.tindie.com/products/Armtronix/wifi-esp8266-solid...

The callback script in the dhcp server pushes an event to a mqtt broker on dhcp commit event.

And all of these orchestrated by home-assistant.io, on top of which, we have also mobile and voice (alexa) integration too.

Re:Show HN: An etcd backed DHCP server by mobilethrow on Monday July 17, 2017 @08:51PM (#14793571)
> I would not recommend anyone use this for anything other than entertainment.

Hate to disappoint you, but I have to try this together with NFQUEUE to power a distributed computing cluster.

I will even use the lease information to implement a host-side firewall, BCP-38 style!

maniacal laughter

Re:Show HN: An etcd backed DHCP server by philsnow on Monday July 17, 2017 @08:11PM (#14793372)
nice work

> I would not recommend anyone use this for anything other than entertainment.

For what it's worth, we used a similar setup at a previous huge employer, but using powerdns with a custom backend adapter that hit a zookeeper cluster, serving a tiny subset of our DNS records (with really short TTLs so that changing ZK resulted in prompt DNS changes). We used this for Real Work, and it worked really well.

So I think your approach is probably fine.

Re:Show HN: An etcd backed DHCP server by _e on Monday July 17, 2017 @08:28PM (#14793433)
I like the idea of triggering home automation just by connecting to the network. What's the status on that part of the project?
Re:Show HN: An etcd backed DHCP server by lclarkmichalek on Tuesday July 18, 2017 @02:48AM (#14794700)
Shall write it today. Don't know how useful it'll be to people. Plan is to turn on door/hallway (Hue) lights when my phone's mac address shows up after having been gone for 15 mins (I have a low lease duration, which gives better granularity). Then poll a (Hue) motion sensor on the stairs to know when the lights can be turned off.

Shall also have to do some stuff to correlate brightness with time of day.