Can I create a custom node id in OpenWRT?

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!

Unfortunately no, you can’t just create a random node ID and have it be valid. It’s a hash of the public cryptography key, and the keys require a proof of work algorithm to generate.

It is possible to pre-generate keys to use via zerotier-idtool, but I don’t know if that’s available on OpenWRT or not. They keys don’t need to be generated on the router, though. Either way, to solve your problem, you’ll likely need to generate the keys externally & configure the routers with said pre-generated keys.

Note: ZeroTier didn’t create the OpenWRT port. It is a community developed project.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.