title: How to get IP which is using for internet connection in Delphi
body: <p>I have a few network adapters in my system:</p>
  
  <ul>
  <li>WiFI (to my home router)</li>
  <li>VPN connection (using Windows PPTP)</li>
  <li>VPN Connection (OpenVPN)</li>
  </ul>
  
  <p>When I'm only connected to WiFI - my IP address is 192.168.1.101 (gateway 192.168.1.1)
  Activating VPN connections brings me next IP's (ex. (PPTP) 192.168.90.101, (OpenVPN) 10.9.0.6)</p>
  
  <p>Question is: How to determine which IP address is "default" for internet connection?</p>
  
  <p>Scenarios:</p>
  
  <p>No 1 - only WiFi - ER (Expected Result): 192.168.1.101</p>
  
  <p>No 2 - WiFi + PPTP (with "Use default gateway on remote network") - ER: 192.168.90.101</p>
  
  <p>No 3 - WiFi + PPTP (without "Use default gateway on remote network") - ER: 192.168.1.101</p>
  
  <p>No 4 - WiFi + OpenVPN - ER: 192.168.1.101</p>
  
  <p>And so on...</p>
  
  <p>Btw. IP from OpenVPN is never returned. This network doesn't route internet connections.</p>
  
  <p>When I use tracert - I can read this information looking on what is first entry in result. But I have to get this information using Delphi or external library used from Delphi app. </p>
  
  <p>I'm using Delphi XE3.</p>
  
  <p>Any ideas? Thanks for help!</p>
  
  <p>PS. <a href="https://stackoverflow.com/questions/18378630/get-information-about-the-installed-network-adapters">Get information about the installed network adapters</a> I tried this solution, but there is no info that NIC is default for internet.</p>
  
  <p>Best regards,
  Robert</p>