Hello! Answering this question in many forums, no one could answer me, so PLEASE help!
I have an Android device connected to a Linux device via a USB modem.
On an Android device, I have a front-end browser application (html, js, css), and on a Linux device, I have a back-end (node.js).
There is a socket connection between the interface and the internal end with a specific IP: PORT.
Android Gateway is a Linux device. The Linux device is connected to the local network.
When the Android device is connected to the Linux device, the Linux device initializes a new network interface named usb0 with a static IP address.
Sockets are based on a network IP address that is the same for each instance of the front-end and external servers.
I have more than 5 instances of the same interface and external devices connected to the local network.
Is there a way to find the IP address of an external device without its static?
My problem starts when starting all devices at the same time. Sometimes the Android device in instance 1 connects to the Linux device from another instance, and I want to prevent this by not connecting to usb0 from Android, but to eth0 of the DHCP device on Linux. I never know what the IP address will be on the Linux device, but an external application requires IP: PORT to connect.
PORT is defined so that the connection string is {IP + ": 3000"}
I know that I see all the IP addresses on the network with arp or similar, but I need to do this automatically in the front-end application when the application starts.
I want to find the first IP address of the device to which the Android device is connected. This is always the front-end Linux interface.
Or, if it is not possible to block an Android device to connect another instance with IP tables on a Linux device.
PS I know that Android is also Linux, but anyone who wants to answer will know what I'm talking about.