I have a network setup and running flawlessly on several OpenWRT routers.
We’re using a custom OpenWRT firmware on the routers, compiled through the image builder. So any and all files can be edited for customization.
I have the config file setup as follows:
config zerotier 'default'
option enabled '1'
option interface 'wwan0'
list join '<redacted>'
On first boot when the router is flashed, ZeroTier will automatically create a public key, private key, and generate the node_id. We then label each node on ZT with the device id we’ve assigned it.
The problem comes in when I do a factory reset. Because I’ve left the keys and node_id blank when I built the firmware, OpenWRT creates a another private key, public key, and node_id. This adds a new entry into my ZT network which isn’t authorized, and also has left the old entry. If 5 units got factory reset that day, I would have to ssh into each router, get the routers device id and match it with our database, then update the new one and delete the old one.
My idea was to build a script which creates the node_id based on the hardware Mac_address of the router. This will be unique between our routers, and if they factory reset, or we remotely upgrade the firmware to our latest version, it will keep the same node_id.
Is this something that can be done, and how do I go about doing this?
Thanks!