Search code examples
pythonscapypacket-snifferswinpcapsniffing

Unknown pypcap network interface 'eth0' error with python2 scapy on windows 10 machine


I am trying to create a simple web monitoring app with scapy(2.4.3), python 2.7 on a windows 10 machine. I also have winpcap(5.0.9983.830) installed.

This is the code I am trying to run:

def http_header(packet):
    print packet

sniff(iface='eth0', prn=http_header)

And this is the error it throws:

raise ValueError("Unknown pypcap network interface %r" % pcap_name)
ValueError: Unknown pypcap network interface 'eth0'

I also installed .Microsoft Visual C++ Compiler for Python 2.7 just to be safe, as other solutions pointed out, but had no success. Also tried re-installing scapy, winpcap and recreating the Virtual Environment, but again had no luck.


Solution

  • Your interface is not called eth0 if you are using Windows.

    You can use ipconfig /all to see all your network interfaces, and you can use the description value of the Ethernet interface as the interface name for Scapy. So for example in my laptop it is:

    IFACE_NAME="Intel(R) Ethernet Connection (2) I219-LM"
    sniff(iface=IFACE_NAME, prn=http_header)