My project has a server and several client Pis on a local network. The goal is to have the server sends commands to all active/online client Pis.

To facilitate this, my idea is that once a client has booted, it checks in to the server so the server knows it's online and where to find it. I've avoided the nmap solution in this post because I feel there's a more elegant solution since the client Pis can be running any helpful identification service to make this easier.

My current prototype has the server sending UDP broadcast messages. The client Pis run a listening script that, upon receiving the broadcast, send a message back to the ip of the broadcast (the address of the server) with the appropriate info. The server then knows where to send commands to clients once they've checked in. (Weird side note, my Pi client receives/recognizes roughly only 5% of the broadcast messages sent out).

What is the better design decision? This post suggests using UPnP / DLAN, however the only examples I've found are for media streaming devices (which seems to go far beyond the needs / complexity of my project).

The other option I've found is using Bonjour. The server would configure a host name that all clients would know and be able to send messages to (essentially saying they're alive and online). Additionally, the client Pis could setup their own hostnames.

Please let me know if one makes more sense for more application or if there is something else I should research. I appreciate any advice!

  • Is the server also the dhcp server? Then you got the IP addresses of connected clients anyhow. Otherwise, if clients have a simple naming scheme like -- let's say -- pi1, pi2 etc, the server could scan all pi{1..20}.local clients (simply install avahi if not yet done). – Philippos Apr 5 '17 at 14:22
  • The server is not the DHCP server. Your other recommendation might be a perfect simple solution - will update once implemented. – Grant G Apr 5 '17 at 14:53

For a similar application, I'm using a very trivial approach that works pretty well: wget.

On the server I have a simple page, client.php, retrieved by the client; it's here where you add the server side code.

  echo  $_SERVER["REMOTE_ADDR"] .
  ":" . $_SERVER["REMOTE_PORT"] .
  ":" . filter_input( INPUT_GET, 'host', FILTER_SANITIZE_URL );

On the client side, at startup and/or on a cron process, present itself to the server:

 wget -o /dev/null -O /tmp/reply http://<server>/client.php?host=$(hostname)

The client.php will receive the hostname on the 'host' variable and from the header, you can extract the caller IP address (and port). At the same time, client.php, can return other information to the client, saved on /tmp/reply.

I use to do this, which is a free server management tool written in Python. I have see this too for my home automation, and for large scale industrial iot projects. Clients (minions) connect to a server (master) and the master can list active clients, manage their configuration, and send commands to one or all.

Check out my project on GitHub, which gets you started with salt stack for home automation.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.