Python scapy arp request not working in virtualbox on internal network. Why?

54 views Asked by At
answered, unanswered = srp(Ether("ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.3.0/24"), timeout=1)
print(answered.summary())

Running above code gives me no results on a Internal Network in VirtualBox.

However, running something like netdiscover -r 192.168.3.0/24 detects the VMs and their corresponding MAC addressses perfectly fine. The code also works when using other network settings like NAT Networking in VirtualBox so it seems like it is the issues with Internal Network setting.

Is there a way to make this work using Internal Network?

1

There are 1 answers

0
Vergar On

I spent a day trying to figure this out and once I posted a question I found a solution. Here it is if someone has similar issue.

The issue has nothing to do with Internal Network so my theory was wrong, I just had to specify the network interface. The below code works as expected.

answered, unanswered = srp(Ether("ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.3.0/24"), timeout=1, iface="eth0")
print(answered.summary())

I figured it out by playing around with "arping" in command-line and noticed I had to specify network interface so tried that with scapy and it worked. Funny thing is all the tutorials or AI generated code didn't include the interface.