This Python script uses Scapy to perform a simple ARP scan across a given subnet, allowing you to discover active devices (IP ↔ MAC addresses) on the local network. It supports both Windows and Linux environments, with small differences between versions.
- Scans a specified subnet using ARP requests.
- Shows IP and MAC addresses of discovered devices.
- Optional verbose output.
- Allows saving results to a text file.
- Compatible with both Windows and Linux.
- Python 3.8+
- Scapy library
To install Scapy:
pip install scapyWindows does not require root privileges but may need Administrator access to send raw packets.
python script_windows.py -i Ethernet -s 192.168.1.0/24 -t 3 -v -o results.txt| Option | Description |
|---|---|
-i [iface] |
Specify the network interface (e.g., Ethernet, Wi-Fi) |
-s [subnet] |
Target subnet (e.g., 192.168.1.0/24) |
-t [timeout] |
Timeout in seconds (default: 2) |
-v |
Enable verbose output |
-o [file] |
Save results to a file |
-h, --help |
Show help message |
192.168.1.1 -> 74:D4:35:AB:12:EF
192.168.1.4 -> 58:D0:6E:22:AA:34
If -o is used, results are saved to the specified file.
Linux requires root privileges to send layer 2 packets.
sudo python3 script_linux.py -i eth0 -s 192.168.1.0/24 -t 3 -v -o scan.txtIf you do not run it as root, the script will exit with:
please run as root
Same as Windows version:
-i [iface]→ Interface name (e.g.,eth0,wlan0)-s [subnet]→ Subnet to scan-t [timeout]→ Timeout value-v→ Verbose mode-o [file]→ Output file-h, --help→ Help
- The script uses
srp()(send and receive packets at layer 2) — ideal for local network discovery. - Works only on LAN networks (not over the internet).
- The Linux version performs a root check using
os.geteuid()and enforces interface selection with-i. - The Windows version doesn’t enforce root but allows scanning with
srp()directly.
When scanning 192.168.1.0/24, typical output:
192.168.1.1 -> 3C:7C:3F:90:12:89
192.168.1.5 -> 20:47:47:19:02:AA
192.168.1.10 -> 5C:D0:6E:55:AF:33
192.168.1.1 -> 3C:7C:3F:90:12:89
192.168.1.5 -> 20:47:47:19:02:AA
192.168.1.10 -> 5C:D0:6E:55:AF:33
- “Scapy not found” → Run
pip install scapy - “please run as root” (Linux) → Use
sudo - No output → Check your interface (
-i) and subnet correctness. - PermissionError (Windows) → Run terminal as Administrator.
Created for educational and ethical network testing using Scapy. Do not use this tool on networks you don’t own or have permission to scan.