Nerves Autodiscovery with MNDP - The MikroTik Device Discovery Protocol

Hi,

i’ve started my first library based on the discussion in We should make some tooling for mDNS/local nerves devices called MNDP and it implements the MikroTik Device Discovery Protocol.

With this, you have a dependeny free way to find all your Nerves and MikroTik devices on your network.

To start add it to your nerves project dependencies (no hex.pm for now until version 0.1.0 is ready). The application will be automatically started.

def deps do
  [
    {:mndp, github: "kevinschweikert/mndp"}
  ]
end

There is a Mix task included to scan for devices for 15s. This will be improved when i implement subscribing so that we can scan for as long as we want and get the results back in realtime.

> mix discover
Searching for devices...
IDENTITY        MAC                     IPV4            INTERFACE       UPTIME
nerves-2a0c     BE:FE:21:C8:80:A1       172.31.199.73   usb0            1605

Thanks to the mdns_lite library for many inspirations and a part of the code was adapted for this library.

I would be happy, if you could try this with your devices, give feedback, open an issue or a PR. Have a look at the todo/idea list in the README to get a feeling for the current state.

Happy to answer any questions!

12 Likes

I just fitted my home with Mikrotik equipment recently, gonna try this out. Cool project!

2 Likes

Fantastic! Gotta try it :slight_smile:

2 Likes

I just tried it out. That’s really cool, and I’ll have to look into this more.

I usually use Elixir scripts rather than Mix tasks, so I converted the task to one. It’s a copy/paste of your code, but it lets me run discovery from any directory. MNDP Discovery Script · GitHub

Great work!

2 Likes

I think this could be a very good case for distributing as a mix escripts. It should be easy to publish to hex, and use it from the CLI.

1 Like

I like the ideas of having a script/escript. I will add a CLI module so it will be easier to start it in a script and can be updated by the library itself. I will also look into escrips and how they can be installed from Hex. This sounds like a nice way for people to have the discover functionality globally available!
Thanks for your input!

2 Likes

Quick update, since i first posted about this package. I’ve added the following:

The two things missing for me, for a first versioned release is the cleanup of the config management and a feature, that per spec you should answer a discovery request packet, so that you can find devices faster. Because i seperated sender and listener i have to find out, which sender is responsible for the response of the received discovery request.

1 Like

awesome library!

[edit] after reading the code this is LLDP so not MDNS, please ignore my question :slight_smile:

My understanding, is that this is fully mdns compliant, right? So it would be possible to wire it into other beam systems like libcluster or khepri or is this solely nerves?

Released with version 0.1.0 on Hex :tada:

4 Likes

Fantastic :sparkling_heart:

Mind doing a PR to put it in nerves_livebook?

It will be in the next release! Include mndp to support device discovery by fhunleth · Pull Request #576 · nerves-livebook/nerves_livebook · GitHub

3 Likes

Thanks @fhunleth for all your fixes and the integration into nerves_livebook!

3 Likes