嗨,我一直在排除带有 2 个 NIC 的服务器和带有有线和无线网卡的笔记本电脑的网络问题。如何强制从特定适配器发送 PING 和 TELNET?我知道这是 Windows 的问题。关闭其中一个适配器不是一个选项,我总是通过其中一个适配器连接。必须有一些命令行选项来优先选择其中一个适配器。
谢谢
答案1
您可以设置静态路由:
route add (destination subnet) MASK (destination subnet mask) (gateway) IF (interface)
欲了解更多信息,请查看微软的文档route
答案2
可能更简单的方法是使用 -S 开关,它可以让您指定源 IP 地址(有关更多信息,请参阅 ping /?)。
您可以做的另一件事是更改绑定顺序,以满足您的“选择优先使用一个适配器而不是另一个适配器”的要求。虽然它因 Windows 操作系统而异,但它的位置与此示例类似:对于 Windows 7,右键单击“网络”,然后单击“属性”。然后单击“更改适配器设置”。然后单击菜单“高级”>“高级设置”,并将您想要优先的连接移到顶部。
从 Windows 7(版本 6.1 内部版本 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 文档指出它只能用于 IPV6(不正确) 适用于: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 - 使用 Ping 命令(Windows 7 和 Server 2008 R2)(也缺少 -S srcaddr)
答案3
所选适配器基于路由表。您可以通过运行“route print”或“netstat -r”来检查路由表。每个条目都有一个度量,该度量决定了路由的权重 - 数字越小越好。您可以使用“route”命令来操作路由表。有关详细信息,请参阅 route /?。