Multiple network interfaces: telling OH2 the one to use

Reading some posts here and from own experience: openHAB2 (in my case 2.2 stable) choses wlan0 before eth0, if it finds both network interfaces.
is there a way to tell openHAB to use a specific network interface?

In Paper UI, under Configuration -> System -> Network Settings, try setting the Primary Address.

as disussed here:

I think, this parameter is just to set the subnet (not a IP-address). What I’d like to do, is to tell openHAB to use a NIC (instead of a subnet) - I know, the IP-address and subnet of the OH-Server should be either static or “static DHCP lease”. But this parameter doesn’t seem to address this.

besides, my assumptions are:

  • the “primary NIC” will that one, which traffice openHAB uses
  • if there are multiple NICs, all others will be “ignored”

This behaviour seems to be the case, as I recently tested my remote Pi in my home network with both eth0 and wlan0 activated - wlan0 got all the traffic and eth0 traffic was ignored.

My second bet would be, this is ESH-related - not OH-core?

Not sure what you mean by this. In the case of OH2 bindings, if they are written to use the setNetworkAddressService API like this, then they should use the network interface associated with the Primary Address when they bind a socket to the Primary Address.

Arguably, there are bindings that don’t do this (such as the OH1 bindings and possibly some other OH2 bindings), so I guess it depends on what you’re trying to accomplish.

Thanks for your thoughts. My usecase is to have all OH2 related traffic coming in eth0 and using wlan0 for another not directly OH2 related purpose but to have some information brought into from my guest-WiFi…

If I understand your last post correctly, legacy bindings could use either NIC (or some ramdonly chosen) as do some OH2 bindings… I have to think about it - and perhaps make some more intense tests…

Exactly. Unfortunately, I’m not aware of a way to force everything to a single network interface.

While this seems like the model. There are lots of issues of having everything use the Primary network interface defined in paperui configuration. Those bindings that moved over to using the it now are reverting the changes back to a binding level interface. Each binding should have a configuration option to select the network interface to use. People have problems selecting the correct interface in
paper ui and others like me have devices on different networks, so need to be able to select the interface at the binding level.

Can’t disagree with anything you say. The current implementation definitely lacks some flexibility.