How to have a device’s IP discovered in a network in a simple manner

avahinetwork-interfacenetworkmanager

At the startup I work, we're setting up a device for image capturing and analysis. It's a box with a camera, with Ubuntu Linux embedded, and, let's assume, we don't want to connect a monitor to this device for configuration.

Some guys came with the solution of having a configuration webpage when connecting the device to a notebook through a network cable directly, just like you do with a router or modem, by accessing a well known IP.

It sounds like a solution, but fact is that the device is not a router, and as I see it, it's quite a different context, the device won't be delegating an address to the notebook (making it part of a router's network, where it can have a well known address) since it's not a router.

So I'm now looking for a solution that resembles the experience of configuring a router, but that's not a router, it's for a device that I should be able to access from a well know address. For that, I've dug a bit about zeroconf/APIPA but from zeroconf RFC 3927 the IP address must be one generated "using a pseudo-random number generator with a uniform distribution in the range from 169.254.1.0 to 169.254.254.255 inclusive".

I think a random IP solution may still work, even though it's not a well know address, in case there's any means of discovering which IP this device has got.

Besides this, this device should be using NetworkManager to handle connectivity through the many interfaces it's setup with.

So, to sum up the problem situation:

  • A device must be configured through a local network.
  • This device is ON and using Network Manager to handle connectivity through many interfaces, let's say one interface connectivity gets down, it would be choosing another interface.
  • We were thinking about having an eth0 alias to have eth0 both being handled
    by Network Manager (in context with other interfaces) as well as having fixed IP access through a non-managed (by Network Manager) alias. Not sure whether that's even possible.
  • It's all about device discovering, I've also proposed using nmap to reach the device, but it has two drawbacks: scanning is slow on large networks and it's not a simple webpage access, a client using nmap must be built and used to do the discovery.
  • If there's no means to have simple access in a well known IP, having a random one is also a solution, given that the device can be discovered like a printer in the network or something like this.
  • It may be assumed that the solution can be one to configure a device directly connected to a notebook through a network cable and acquire access to it in a device's configuration webpage as well as one solution where the notebook gets connected to the local network the device is also connected, and be able to access the device discovering it in the network or accessing it through an alternative, exotic and fixed address. Notice that accessing the local network router or using nmap/arp scan is not an option.

What matter should be studied to address this problem? Is there a common approach people use for this?

In my experience I recall configuring my devices but none fitting the problem:

  • Router: Provides an easy to access configuration webpage at a well known address, but it's the router, it's the gateway and it will be delegating my own address.
  • Cubox-i: I have one of these devices, I had to discover it using nmap in my network and access its ssh.
  • Printers: I have never owned one, so I don't know how its device discover/configuration works, but have used them on networks before, they were generally listed in the device settings on a Windows machine. I still have to take a look at "Avahi", "UPnP", "Zeroconf" and other names in the field which I never worked with. Maybe this is the kind of example that may fit the situation.

If there's a simple tool I can run on my Arch Linux and have its IP discovered by other devices like my Android or my Windows notebook, I'd like to know.
I've also thought about broadcasting but I'm not sure this would be OK in all LANs, where broadcasting could be blocked or unreliable (unsure regarding this).

Best Answer

The best way to do this is with avahi which implements multicast-dns (this is what Apple calls Bonjour).

I would disable Network Manager and go with configuring networking in /etc/network/interfaces. The interfaces file supports the ipv4ll method, which uses avahi-autoipd to configure an interface with an IPv4 Link-Layer address (169.254.0.0/16 family).

Next, set up a service in avahi to ensure the host advertises itself via bonjour and add mDNS name resolution to /etc/nsswitch.conf.

If the rest of your systems are configured to resolve mDNS names, it should all work like magic.

Related Question