LanLight: A Minimal Local Network Device Map on Raspberry Pi Zero W
What this is
LanLight is a tiny, local-only network device map: a single small server on a Raspberry Pi Zero W that scans the LAN with arp-scan and serves a minimalist web page showing active IPs, MACs, and vendor hints. It’s designed for makers who want a fast, private way to see what’s on the local network without running heavier tools or uploading metadata to the cloud.
Why this approach
There are fancier network monitors, but they often require heavyweight installs or cloud accounts. LanLight trades features for simplicity: one dependency for scanning, one small Python script for serving results, and a tiny systemd unit to run it at boot. It’s easy to extend for LEDs, Home Assistant, or just to satisfy curiosity.
What you need
- Raspberry Pi Zero W (or any Pi with Wi‑Fi)
- microSD card and power supply
- microUSB serial/SSH access or a USB keyboard + HDMI (initial setup)
- network access for the Pi (Wi‑Fi)
Install and prepare
- Flash Raspberry Pi OS Lite to the microSD and enable SSH (add an empty file named
sshto the boot partition). - Boot the Pi and SSH in. Update packages:
sudo apt update && sudo apt upgrade -y
- Install
arp-scanand Python (these are tiny):
sudo apt install -y arp-scan python3
arp-scan runs as root to send ARP requests; we’ll call it from Python using subprocess.
The tiny server
Drop this single Python file on the Pi (for example /home/pi/lanlight.py):
#!/usr/bin/env python3
import subprocess
from http.server import HTTPServer, BaseHTTPRequestHandler
import html
PORT = 8080
SCAN_CMD = ['sudo', 'arp-scan', '--localnet']
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path != '/':
self.send_error(404)
return
self.send_response(200)
self.send_header('Content-type', 'text/html; charset=utf-8')
self.end_headers()
out = subprocess.run(SCAN_CMD, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
lines = []
for line in out.stdout.splitlines():
parts = line.split('\t')
if len(parts) >= 3 and parts[0].strip():
ip = html.escape(parts[0].strip())
mac = html.escape(parts[1].strip())
vendor = html.escape(parts[2].strip())
lines.append((ip, mac, vendor))
# Minimal inline HTML
self.wfile.write(b"")
self.wfile.write(b"LanLight ")
self.wfile.write(b"")
self.wfile.write(b"")
self.wfile.write(b"LanLight — Local Devices
")
self.wfile.write(b"Scans the local network with arp-scan. Refresh to rescan.
")
self.wfile.write(b"IP MAC Vendor ")
for ip, mac, vendor in lines:
row = f"{ip} {mac} {vendor} ".encode('utf-8')
self.wfile.write(row)
self.wfile.write(b"
Local only — no cloud.
")
self.wfile.write(b"")
if __name__ == '__main__':
server = HTTPServer(('0.0.0.0', PORT), Handler)
print(f'Listening on port {PORT}')
server.serve_forever()
Make it executable:
chmod +x /home/pi/lanlight.py
Allowing arp-scan without a password
Since arp-scan needs root, add a safe sudoers rule so the web server can run it without prompting for a password. Edit a new file:
sudo visudo -f /etc/sudoers.d/lanlight
# Add this single line (replace 'pi' if you use another user):
pi ALL=(ALL) NOPASSWD: /usr/bin/arp-scan
Run at boot
Create a simple systemd unit /etc/systemd/system/lanlight.service:
[Unit]
Description=LanLight local network map
After=network-online.target
[Service]
User=pi
ExecStart=/usr/bin/python3 /home/pi/lanlight.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
Then enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now lanlight.service
Accessing the UI
Point a browser to http://raspberrypi.local:8080 or use the Pi’s IP: http://<pi-ip>:8080. Refresh the page to rescan the network. The page is tiny and works on phones.
Extensions and ideas
- Flash a small LED (GPIO) when new devices appear.
- Cache last scan and show delta (new/removed devices).
- POST simple webhook to local automation when a specific MAC appears.
- Replace
arp-scanwith raw Python Scapy if you want a pure-Python stack.
Troubleshooting
- If the page is empty, run
sudo arp-scan --localnetmanually and confirm output. - Permission denied for arp-scan? Confirm the sudoers file is correct and the path (
/usr/bin/arp-scan) matches. - Slow Wi‑Fi? ARP scans are fast but can be delayed if the AP isolates clients.
Privacy and safety
LanLight does everything locally and does not send data anywhere. The server runs on your LAN and is intentionally minimal. Don’t expose port 8080 to the internet — that defeats the point.
Final note: it’s deliberately small. If you want more inventory features, plug LanLight into your home automation stack. If you like tiny tools that do one thing well, you’ll enjoy extending this one.