Projects / archived
AutoNetworkConfig
A Python script that watches a subnet for new machines and bootstraps them over SSH.
This one is older, but I still like the idea. I wanted to plug a new machine into the network and have it set itself up without me touching it.
What it does
You point it at a network range, a bash script, and an SSH user and key:
python3 network_monitor.py \
-n 192.168.1.0/24 \
-s ./deploy_script.sh \
-u ubuntu \
-k ~/.ssh/id_rsa
Then it loops:
- Scans the subnet with nmap for hosts that are up.
- Skips anything it’s already handled, like the gateway or the machine it’s running on.
- SSHes into anything new with Paramiko and runs the script.
- Records the result in a small SQLite database.
Scans and SSH attempts run in a thread pool so one slow host doesn’t hold up the rest.
The SQLite part
The database is what made it actually usable. For every host it tracks the IP and MAC, the last attempt, the last success, how many times it’s tried, and whether the script ran. That means it doesn’t hammer a box that keeps failing, it doesn’t re-run the setup on something that already succeeded, and it picks up where it left off after a restart.
What I’d do differently now
Honestly, today I’d reach for Ansible for the “run this on new machines” part, or bake the config into the image with something like NixOS so there’s nothing to bootstrap at all. A script that SSHes into anything new on the network with one shared key is also not something I’d run anywhere I didn’t fully control.
But writing it taught me a lot about scanning, idempotency and keeping state about a fleet, and a lot of the homelab stuff came out of thinking about this problem.