title: How to determine whether an IP is from the same LAN programatically in .NET C#
body: <p>I know that if an IP falls outside the Subnet Mask + Local IP rules, it will be only reachable through an Gateway. The problem is that I don't know how to obtain the local IP address, neither the local subnet mask, programatically using .NET.
  Any of you can help me?</p>
  
  <p>I will use this information to squeeze the maximum performance from my batch SQL insertion queue. If the SQL server falls in the same subnet, then it will use an algorithm optimized for mininum latency, otherwise I´ll use one optimized for high latency.</p>