A proactive approach will work if the subnet is small, most home routers have small subnets ... However, in a more complex network, an iterative approach would not be feasible, you would need to use a service discovery protocol such as mdns or ssdp. However, they are probably inaccessible to a web browser, the best option as an alternative would be a server sitting on the Internet, where devices can meet and exchange local IP address information ... However, if the network is quite complex, even devices with the same external The IP address may not be able to communicate between their respective subnets.
source share