Scapy - the interface of a sniffed packet

ori picture ori · May 17, 2015 · Viewed 9.3k times · Source

I'm sniffing with scapy 2.2 on Windows 7 with Python 2.6. Is there a way I can recognize the interface of a sniffed packet? I thought about using the mac address to identify it, but is there a way to do it with scapy?

something like this (doesn't work) -

packet = sniff(count=1, iface='eth0')[0]
print packet.iface  # prints 'eth0' 

Answer

Martin Sundhaug picture Martin Sundhaug · Mar 22, 2017

In scapy, the interface-name the packet was captured on is stored in the property sniffed_on, for example:

    packet.sniffed_on