2

I am creating a simple function, which should collect MAC addresses of all devices in my network.

import scapy.all as scapy

def network_scan(ip):
   arp_request = scapy.ARP(pdst=ip)
   print(arp_request.summary())

network_scan("10.0.2.1/24")

This ARP request returns "ARP who has ?? says ??"

But when I try to request a MAC address of a single IP, it works good:

network_scan("10.0.2.1")

Single IP output: ARP who has 10.0.2.1 says myIP

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
  • Hi, check similar question here https://stackoverflow.com/questions/56226523/how-to-update-the-packages-in-ipython-like-jupyter-spyder ? Does this provide answer to what your question? I have tried the solution in the link myself and it worked. Let me know if this works for you. Make sure to clone and install the correct scapy version as directed in the link. Best regards. – smile Jul 06 '20 at 08:36

1 Answers1

0

The value you passed to the layer ARP is just fine. But your code is not sending/receiving any packets to the network.

you can see the complete solution here: https://www.thepythoncode.com/article/building-network-scanner-using-scapy

now, why it seems to work with your IP? arp_request.summary() try to resolves the IP and saw it was yours. but the scanning part still needs to send packets

fgagnaire
  • 586
  • 5
  • 13