I'm trying to execute a ping with eth1, but the program uses eth0(the default network device). Any tips, tricks, or alternate techniques available?
Asked
Active
Viewed 1.2e+01k times
29
-
What does it mean to execute a ping "with" an interface exactly? – David Schwartz Aug 16 '13 at 22:49
3 Answers
36
From the manual:
-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.
So, answer is:
ping -I eth1 123.123.123.123
GioMac
- 4,444
- 3
- 24
- 41
-
NOTE: ** Be careful when using ping -I, it isn't always unintrusive. If you have a bond0 (teaming NICs) and you ping one of the slaves it will block the network connection until the ping stops .. – Mike Q Sep 09 '22 at 05:24
8
Use the -I
option -
-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
Daniel t.
- 9,061
- 1
- 32
- 36
3
I believe using the -I
option will do this. I had to do it once, but that was some time ago. From the ping man page:
-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.
Paul
- 2,755
- 6
- 24
- 35