windows 我可以尝试通过特定适配器 ping 网站吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3303545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:28:33  来源:igfitidea点击:

Can I try to ping a website through a specific adapter?

windowsnetworkingvbscriptwmi

提问by richb01

I hope this isn't too basic a question. The title kind of asks it all. :-)

我希望这不是一个太基本的问题。标题有点问这一切。:-)

采纳答案by Hyman B Nimble

The ping command will allow strict source routing so you can specify the default gateway to use on the way out. (This assumes your interfaces have distinct gateways i.e. are on different networks)

ping 命令将允许严格的源路由,因此您可以指定要在出路时使用的默认网关。(这假设您的接口具有不同的网关,即位于不同的网络上)

ping -k 192.169.1.1 microsoft.com
        ^ default gateway for desired interface

Using WMI Win32_PingStatus?you can do the same thing where you specify SourceRouteand SourceRouteType(This is essentially the same as using ping -k)

使用 WMI Win32_PingStatus吗?您可以在指定SourceRouteSourceRouteType的地方做同样的事情(这与使用 ping -k 基本相同)

Alternatively:

或者:

If your network interfaces are on the same network, like a LAN card and a wireless adapater you can add a custom ROUTEto your machine, which can send all traffic through a specific interface.

如果您的网络接口在同一个网络上,例如 LAN 卡和无线适配器,您可以向您的机器添加自定义ROUTE,它可以通过特定接口发送所有流量。

From ROUTE HELP:

路线帮助:

route ADD 207.46.0.0 MASK 255.255.0.0  192.168.1.1 METRIC 3 IF 2
        destination^      ^mask        ^gateway     metric^    ^
                                                      Interface^

回答by Subash Abhinov Kasiviswanathan

pingalso has an option in Windows:

ping在 Windows 中也有一个选项:

-S srcaddr     Source address to use.

So you can do something like

所以你可以做类似的事情

ping 10.10.10.1 -l 0 -S 192.168.1.1

where 10.10.10.1 is the destination address and 192.168.1.1 is the address of the source adapter

其中 10.10.10.1 是目标地址,192.168.1.1 是源适配器的地址