Dev.to Security ๐Ÿ” Cybersecurity ๐Ÿ‘ 2 ๐Ÿ“– 4 min read

Which devices appeared after your router baseline? DHCP inventory with Hermes

Two devices can have leases on the same router and tell different stories. In a small test with fictional dnsmasq records, the first collection contained one client, atlas. On the second collection we added beacon. We st

Two devices can have leases on the same router and tell different stories. In a small test with fictional dnsmasq records, the first collection contained one client, atlas. On the second collection we added beacon. We started a fresh collector process each time and kept the same state directory.

Both clients had a lease on the second pass. Only beacon showed up as first seen after baseline. The first successful read had already established atlas as part of the starting inventory. On a third pass we removed beacon from the sample file. Its saved relationship changed to Last known, and its previous IP and observation times remained available. The read-only router_additions tool returned that same historical addition.

This is how Warden House handles new device detection without relying on push notifications or agent installations. It reads what's already there โ€” dnsmasq leases, ARP tables, running services โ€” and compares snapshots over time. No daemon. No root privileges beyond reading /var/lib/misc/dnsmasq.leases and /proc/net/arp.

The problem it solves

You know who's connected to your network today. You might even know who has been here before โ€” if you've been logging long enough. What's harder is answering specific questions about when someone first appeared and whether they're still active right now.

A remembered device could be a laptop that's been on vacation for two weeks but whose last-known IP and MAC are sitting in your state directory. A current-lease device might be an unknown phone that joined during dinner. Mixing these up โ€” treating a stale record as active or mistaking an old lease for a brand-new joiner โ€” is exactly where security gaps appear.

The DHCP file's update time helps you judge the age of an export. Establishing when someone actually joined Wi-Fi takes a separate observation from the access point. Both are needed for a complete picture.

Walkthrough

To investigate your own router, point the collector at a readable dnsmasq lease file or a regularly refreshed export. Supply the issuing router's address with --router. Open Connections, select that router under Scope, and expand a DHCP record. Its first and last observation times tell you when the collector saw the lease.

Here's what the flow looks like:

  1. Run the collector. Start it pointing at your dnsmasq lease file and router.
   python3 dist/warden-house.pyz \
     --dnsmasq /var/lib/misc/dnsmasq.leases \
     --router 192.168.1.1
  1. Open Connections. In the game view, hit C for connections or click the panel. Expand the scope to your target router. Each DHCP record shows first-seen and last-seen timestamps.

  2. Filter by timeline. Compare the DHCP file's last-modified time against the collector's observation window. If the lease file hasn't been written since you started the collector, you may not see anything new yet.

  3. Check remaining devices. Use the Last known tab to see devices that were present in an earlier snapshot but are no longer in the current DHCP output. Their previous IP and observation history remain accessible.

(Screenshot: The Connections panel showing DHCP entries with first-seen and last-seen timestamps, alongside the Last Known tab.)

Integrating with Hermes

Once Hermes is connected to the same inventory, a useful question is "Which DHCP clients first appeared after baseline, and which of those are still in the latest lease snapshot?" Asking for both parts keeps a remembered device from being mistaken for a current lease.

The MCP stdio bridge makes this queryable through conversation rather than requiring manual lookups:

Ask: "What new devices showed up on my home router since last week?"
Hermes calls: router_additions (returns only DHCP entries between last and current snapshot)
Hermes replies: "Two new hosts โ€” beacon (MAC xx:xx:xx) arrived Thursday, atlas was already baselined."

The router_additions tool is read-only and returns only devices added between two snapshots. For the full inventory, use house_inventory, which includes everything the collector has observed regardless of time window.

Both tools run over stdin/stdout via the MCP protocol โ€” no server required, no persistent connection. They work with any Hermes-compatible frontend that supports stdio transport.

Practical considerations

File permissions. Read-only access to /var/lib/misc/dnsmasq.leases and /proc/net/arp is sufficient. The collector never writes to system files โ€” all state stays in the working directory's data folder.

Stale exports. A copy of the dnsmasq file from three days ago will show you yesterday's network. That's fine for retrospective analysis but won't detect today's arrivals until you feed the updated export. Always check the file modification time.

Device identity. DHCP doesn't give names โ€” only MAC addresses and IPs. To resolve MACs to human-readable identifiers, cross-reference with the ARP cache (cat /proc/net/arp) or a mDNS/Bonjour scanner. Warden House stores whatever label source you give it and preserves the provenance in the inventory JSON.

Multiple routers. If your estate spans several access points, run the collector once per subnet and merge with the --merge-dir flag, or run independent instances and compare their states through the dashboard.

Summary

DHCP tracking through passive file reads gives you more visibility than you'd expect from a few lines of shell. The gap between "who's online" and "who joined when" is bridged by keeping chronological snapshots and letting a viewer โ€” game-based or terminal โ€” make the deltas obvious.

If you want to try it yourself, the code is available as a single archive with no dependencies beyond Python 3:

Download v1.0 (.pyz) ยท Source code

Run it locally. Point it at your dnsmasq leases. See what your network looks like when you stop scrolling dashboards and start walking through rooms.

Data note

The example devices above (atlas and beacon) are fictional, drawn from controlled test runs. Real investigations should always compare the collector's observations against live system output before acting on findings.

๐Ÿ“ฐ Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.