Ah well, then you are down to doing lots of networking magic. At least on linux, what I would do is examine the routing table, find the default gateway and then pick the interface address that falls in the same subnet as the gateway. That should take care of 90% of these cases. While I (more or less) know how to do that on linux, I have no idea on the other platforms.
Another alternative is to get a list of interfaces and ask the user to choose, though this is less friendly.
|