0

is there any way to specify destination interface in ping command, like ping -i eth0(destination interface) host. I want to do this so that I can capture packets on host on specific interface specified in ping command. Thanxx in advance!

1
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.
    – Ron Maupin
    Commented Dec 17, 2020 at 15:21

2 Answers 2

2

is there any way to specify destination interface in ping command, like ping -i eth0(destination interface) host.

The destination IP address is what specifies the destination interface.

You cannot ping a raw interface, it must be bound with an IP address - that's what you ping.

I want to do this so that I can capture packets on host on specific interface specified in ping command.

For packet capturing you'll need to find out which interface the destination IP address in question is bound to.

3
  • How would I find that?? Means which interface is bound to host address? Commented Feb 10, 2020 at 13:08
  • I just want to know which interface accepts ping request Commented Feb 10, 2020 at 13:30
  • You ping a specific IP address and have that address bound to/associated with a specific interface. Most host OSes have a tool to look up the bindings, e.g. in Windows ipconfig. Note that host issues and configurations are off-topic here.
    – Zac67
    Commented Feb 10, 2020 at 13:35
1

Not really, only if the target has different IP addresses applied to its interfaces. The only thing an IP packet contains about the destination is the destination address. If the remote host has different addresses on different interfaces, the packet will be routed towards the particular address. If the ECHO REQUEST gets to a host configured with that IP address, it will answer.

You can however, on most systems which can have multiple addresses, specify the source address.

On Cisco IOS, give ping ip and answer the prompts (extended commands=y). On most Unix-derived systems, ping -I interface. See documentation for your system for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.