On Windows, how to determine route for IP destination?
In Powershell:
Find-NetRoute -RemoteIPAddress "10.0.0.34" | Select-Object ifIndex,DestinationPrefix,NextHop,RouteMetric -Last 1
ifIndex DestinationPrefix NextHop RouteMetric
------- ----------------- ------- -----------
49 10.0.0.0/24 10.64.130.4 0
Yep. Open a command line and type tracert 1.2.3.4
The pathping
command is similar to tracert
but includes the outgoing interface.
Using cygwin, this command gives the outgoing IP/interface for a particular destination (specified by $HOST
):
pathping -n -w 1 -h 1 -q 1 $HOST | head -n 4 | tail -n 1 | awk '{print $2}'