Ping from specific network adapter on Windows

Hey, I've been troubleshooting network issues on servers with 2 NICs and laptops with wired and wireless cards. How can I force the PING and TELNET to be sent from a specific adapter? I know it's a trouble with windows. Turning off one of the adapters is not an option, I am always connected through one of the adapters. There must be some command line option to prefer one adapter over the other.

Thanks


You can set a static route:

route add (destination subnet) MASK (destination subnet mask) (gateway) IF (interface)

For more info, check out Microsoft's documentation on route


Probably easier is to use the -S switch, which lets you specify the source IP address (see ping /? for more infos).

Another thing you can do is change the binding order, which meets your "option to prefer one adapter over the other". Although it varies from Windows OS to OS, it is in a similar location as this example: For Windows 7 you right click on Network, and click properties. Then you click on ""Change adapter settings". Then click on the menu Advanced>Advanced Settings and move the connection you want to have priority to the top.

From Windows 7 (Version 6.1 Build 7601: Service Pack 1) ping /?

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
        [-r count] [-s count] [[-j host-list] | [-k host-list]]
        [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name


Options:
-t             Ping the specified host until stopped.
               To see statistics and continue - type Control-Break;
               To stop - type Control-C.
-a             Resolve addresses to hostnames.
-n count       Number of echo requests to send.
-l size        Send buffer size.
-f             Set Don't Fragment flag in packet (IPv4-only).
-i TTL         Time To Live.
-v TOS         Type Of Service (IPv4-only. This setting has been deprecated
               and has no effect on the type of service field in the IP Header).
-r count       Record route for count hops (IPv4-only).
-s count       Timestamp for count hops (IPv4-only).
-j host-list   Loose source route along host-list (IPv4-only).
-k host-list   Strict source route along host-list (IPv4-only).
-w timeout     Timeout in milliseconds to wait for each reply.
-R             Use routing header to test reverse route also (IPv6-only).
-S srcaddr     Source address to use.
-4             Force using IPv4.
-6             Force using IPv6.

Microsoft TechNet Ping Documentation which states it can only be used for IPV6 (not correct) Applies to: Windows Server 2003, Windows Vista, Windows XP, Windows Server 2008, Windows 7, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2000, Windows Server 2012, Windows 8

Microsoft TechNet - Using the Ping Command (Windows 7 and Server 2008 R2) (also missing -S srcaddr)


The adapter chosen is based on the routing tables. You can examine the routing tables by running 'route print' or 'netstat -r'. Each entry will have a metric which dictates the weighting of the route - lower numbers are preferred. You can manipulate the routing table with the 'route' command. route /? for details.