Why GetBestInterfaceEx doesn't consider routes added via command line?
Consider the case where there are two network interfaces connected to the system (Ethernet and WiFi). Both will add 0.0.0.0/0 route in the routing table but, one of the interface will have a lower metric (say Ethernet gets the lower metric). GetBestInterfaceEx gives correct results for any given IP i.e. Ethernet.
But, consider the case where we add a specific route for 1.1.1.1/32 to go via WiFi instead of Ethernet using "route add" command. In this case, GetBestInterfaceEx doesn't consider the newly added route and still returns WiFi as the best interface for 1.1.1.1 destination.
In case a VPN adds the same route for 1.1.1.1/32 to go via VPN adapter instead of Ethernet, even in this case, the API correctly gives the VPN adapter as the best interface.
Why does the MSDN API consider the route added by VPN different than the one added using route add command?