如何从 eth1 而不是 eth0 显式 Ping

use*_*814 20 linux ping eth0

我正在尝试使用 eth1 执行 ping,但该程序使用 eth0(默认网络设备)。任何提示、技巧或替代技术可用?

Gio*_*Mac 24

从手册:

  -I interface
          interface is either an address, or an interface name.  If interface is an address, it sets source
          address to specified interface address.  If interface in an interface name, it sets source inter?
          face  to  specified  interface.   For  ping6, when doing ping to a link-local scope address, link
          specification (by the '%'-notation in destination, or by this option) is required.
Run Code Online (Sandbox Code Playgroud)

所以,答案是:

ping -I eth1 123.123.123.123
Run Code Online (Sandbox Code Playgroud)


Dan*_* t. 6

使用-I选项 -

-I interface address
          Set  source address to specified interface address. Argument may
          be numeric IP address or name of device. When pinging IPv6 link-
          local address this option is required.
Run Code Online (Sandbox Code Playgroud)

ping -I eth1 www.google.com