title: Given an IP address, find interface on same subnet
body: <p>I'm trying to create a bash script and a small part of it requires figuring out if, given an IP address of another computer, what interface is on that same network.</p>
  
  <p>So if my computer is has the following interfaces (not including lo):</p>
  
  <pre><code>eth0      Link encap:Ethernet  HWaddr XX
            inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.0
  
  wlan0     Link encap:Ethernet  HWaddr XX
            inet addr:192.168.5.100  Bcast:192.168.5.255  Mask:255.255.255.0
  </code></pre>
  
  <p>and I know that there is a computer at the following address:</p>
  
  <pre><code>192.168.0.101
  </code></pre>
  
  <p>is there a simple way to extract the answer <code>eth0</code>?</p>
  
  <p>P.S. This question is <strong>NOT</strong> asking about getting the the interface given the address of my own computer like <a href="https://stackoverflow.com/questions/4986169/how-can-i-fetch-the-ethernet-port-given-the-ip-address">this post is</a>.</p>