如何从eth1而不是eth0显式Ping

我试图用eth1执行ping,但程序使用eth0(默认的networking设备)。 任何提示,技巧或替代技术可用?

从手册:

-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 

使用-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 http://www.google.com

我相信使用-I选项将做到这一点。 我不得不这样做一次,但那是在一段时间之前。 从ping手册页:

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