Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This seems to be quite a trivial problem, but after some searching I can't stil figure out the answer. One can run tcpdump using "any" as the interface description, ie:

 # tcpdump -i any -n host 192.168.0.1

Is there any way to force tcpdump to show on which interface displayed packet was captured?

Update:

As more people confirmed this is probably not possible with vanilla tcpdump, can someone propose a solution to mentioned problem? Perhaps different sniffer?

General issue is as follows: On a system with 50 interfaces determine what is inbound interface for packets coming from specific ip address.

share|improve this question

4 Answers 4

I don't know of any answer to that either. I find no option for it, can't recall ever seeing one, and am rather certain that the tcpdump format doesn't include an interface identifier. I think you'll have to start one tcpdump instance for each interface and log to respective files.

share|improve this answer
    
I concur. Typically when I'm sniffing traffic, I already know where the traffic is coming from or where it's going. If I have to figure that out, I have bigger fish to fry first... –  Corey S. Jan 20 '11 at 17:47
2  
I really need this functionality very often. I have several interfaces, lots of vlan interfaces, with IGP and BGP on top of this. Finding out how the packets are flowing is essential very often. I can manually check the outbound interface by examining the current routing table. But if I have to find the way packets are coming from the internet, sometimes I have to do blind checking, just by starting tcpdump on most probable interfaces. :( –  mdrozdziel Jan 21 '11 at 1:13

You can use the -e option to print the ethernet headers, then you can correlate the src/dst MAC addresses with your network interfaces ;).

share|improve this answer

Assuming this is on Linux, you could add an iptables rule to match the packet you are looking for and log it. Iptables log includes ingress and egress interfaces, among other things.

share|improve this answer
for interface in `ifconfig | grep '^[a-z0-9]' | awk '{print $1}'`;do echo $interface;tcpdump -i $interface -nn -c 25;done

Adjust -c as needed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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