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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.