我正在尝试使用 eth1 执行 ping,但程序使用 eth0(默认网络设备)。有什么提示、技巧或替代技术可用吗?
答案1
来自手册:
-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
答案2
使用-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
答案3
我相信使用该-I
选项可以做到这一点。我不得不这样做一次,但那是很久以前的事了。摘自 ping 手册页:
-I 接口地址
将源地址设置为指定的接口地址。参数可以是数字 IP 地址或设备名称。当 ping IPv6 链路本地地址时,此选项是必需的。