如何从eth1而不是eth0显式Ping


16

我正在尝试使用eth1执行ping操作,但是程序使用eth0(默认网络设备)。有技巧,窍门或其他可用技巧吗?


完全执行“与”接口的ping是什么意思?
大卫·史瓦兹

Answers:


20

从手册中:

  -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.

因此,答案是:

ping -I eth1 123.123.123.123

5

使用-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.

ping -I eth1 www.google.com


2

我相信使用该-I选项可以做到这一点。我不得不做一次,但这是前一段时间。在ping手册页中:

-I接口地址
将源地址设置为指定的接口地址。参数可以是数字IP地址或设备名称。ping IPv6链接本地地址时,此选项是必需的。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.