Scapy/ARP request does not work for multiple/range IPs. Only for a single IP request

Viewed 475

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

1 Answers

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

Related