Hi all,


Recently I came across a problem with my software in a multi-NIC environment. The problem I have is, that I would like to find out the network interface (actually just it's IP), that is used when communicating with a specific external IP. Let's say my host has two NICs, one (call it eth0) is set to 192.168.1.100 and the other (eth1) to 10.11.12.13, and routing on the host is set that 10.0.0.0 goes over the 10.11.12.13 interface while all the other traffic goes over the 192.168.1.100 interface.

What I would like is a pseudo

QString MyIP=MyNIC_IP(ForeignAddress);

which would return '192.168.1.100' for a ForeignAddress 'www.google.com'
and '10.11.12.13' for a ForeignAddress '10.20.30.40'

... but can't seem to get a proper idea as to how to do it. Any hints/help would be greatly appreciated.