Search code examples
pythonscapypython-netifaces

scapy - srp doesnt send my packet to the correct network interface


I work on windows 10 machine and I am using scapy for some project I am doing.

When I use the sniff function to sniff packets form my ethernet interface it is working as expected but when I use srp1 to send packet from the same interface it send my packet trough my vEthernet interface and not trough my physical ethernet interface(so the packet never gets to it destination).

Here is my code of sniff versus srp1:

a = sniff(count = 1, iface = "Ethernet")
p = srp1(pkt, iface = "Ethernet")

as you can see in both calls I use "Ethernet" interface name.

Can someone tell me what to do so my packet will be send trough Ethernet and not vEthernet?


Solution

  • If you open a Scapy shell and type IFACES (Windows only ATM), you will be shown the exact list of interfaces.

    You can then use the interface object, rather than the name. (see help(IFACES) for the various util functions such as IFACES.dev_from_id()... to get it).

    Example:

    from scapy.arch.windows import IFACES
    a = IFACES.dev_from_id(5)
    sr1(IP(dst="www.google.com")/ICMP(), iface=a)
    

    See also https://stackoverflow.com/a/55093154/5459467