How can I determine the IP route taken for a specific IP destination (without looking at "route print" and figuring it out manually)?
In OS X there's route get 1.2.34 and in Linux there's /sbin/ip route get 1.2.3.4. Is there anything like that on Windows?
3 Answers
Yep. Open a command line and type tracert 1.2.3.4
In Powershell:
Find-NetRoute -RemoteIPAddress "10.0.0.34" | Select-Object ifIndex,InterfaceAlias,DestinationPrefix,NextHop,RouteMetric -Last 1
ifIndex : 10
InterfaceAlias : Ethernet 2
DestinationPrefix : 10.64.0.0/10
NextHop : 0.0.0.0
RouteMetric : 0 3 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}'