Modbus TCP not working across secondary subnet with dual-interface setup

Hi everyone,
I’m using OpenHAB with a dual-interface server. The main network is 192.168.1.0/24, and the Modbus devices are on a separate subnet 10.42.42.0/24.
The OpenHAB server has access to both networks — the primary IP is 192.168.1.1.

I’m using the Modbus binding to connect to a device at 10.42.42.2:1502, but I keep getting connection timeouts.


> 2025-04-13 17:48:54.016 [WARN ] [ing.ModbusSlaveConnectionFactoryImpl] - Connect reached max tries 1, throwing last error: Connect timed out. Connection TCPMasterConnection [m_Socket=Socket[unconnected], m_Timeout=3000, m_Connected=false, m_Address=/10.42.42.2, m_Port=1502, m_ModbusTransport=net.wimpi.modbus.io.ModbusTCPTransport@dfd160c, m_ConnectTimeoutMillis=10000, rtuEncoded=false]. Endpoint ModbusIPSlaveEndpoint [address=10.42.42.2, port=1502] 
> 2025-04-13 17:48:54.016 [WARN ] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection TCPMasterConnection [m_Socket=Socket[unconnected], m_Timeout=3000, m_Connected=false, m_Address=/10.42.42.2, m_Port=1502, m_ModbusTransport=net.wimpi.modbus.io.ModbusTCPTransport@dfd160c, m_ConnectTimeoutMillis=10000, rtuEncoded=false] for endpoint ModbusIPSlaveEndpoint [address=10.42.42.2, port=1502]: Connect timed out 
> 2025-04-13 17:48:54.016 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusIPSlaveEndpoint [address=10.42.42.2, port=1502] -- aborting request ModbusReadRequestBlueprint [slaveId=71, functionCode=READ_MULTIPLE_REGISTERS, start=56, length=1, maxTries=3] [operation ID 0b227963-c7d8-44f5-b070-026df8cfc5bb]

The Port is open an Ping is working. Is there a way to force the Modbus binding to use the second interface (e.g. via localAddress) or any other idea why the connection might fail?

Thanks in advance!

Have you setup both network cards in OpenHAB?

Yes I did setup both network cards as follows:

do you have any idea on how to give modbus the relevant hint?

The interesting thing is, that the Kostal-Binding is able to connect to the IP 10.42.X.X whereas Modbus TCP can’t.

Have you gotten the Modbus to work at all? I would try it on a flat network first to see if it is a network issue or a Modbus issue. Yes Modbus is a standard that some vendors do silly things with .

yes the Modbus Binding is working if I’m using the 192.168 interface but not if I’m using the second interface.