title: Host interface or route for remote address
body: <p>How do I know which interface will be used for a specific remote address?</p>
  <p>Say, I have two interfaces. One of them is 192.168.0.50/24, the other is 10.0.2.30/21 and all traffic is routed through it. So, for 192.168.0.100 I expect 192.168.0.50, for 10.0.3.40 or 8.8.8.8 I expect 10.0.2.30.</p>
  <p>I'd like to ask the OS, as it somehow binds the address to a specific interface when I do <code>socket.connect</code> or <code>socket.sendto</code>. So how do I find out the address the OS <em>would</em> bind the socket on <code>socket.connect</code> without doing <code>socket.connect</code>?</p>
  <p>There are two goals: to &quot;test&quot; the routing table and to bind socket to a specific port and the adapter that is accessible by the peer.</p>
  <p>Unlike in <a href="https://stackoverflow.com/questions/8437726">Can Python select what network adapter when opening a socket?</a>, I don't have adapters with overlapping addresses and I don't know the address of the adapter that socket would be bound to. My goal is to find this address.</p>