Specifying or deducting interface name

I am performing automated Kubernetes set up where Zerotier is one of the moving pieces.
I need to know an interface name beforehand. So, when things are deployed together, interface is known and templated in, for FRR, OSPF router in my case

What I know on set up:

  1. Network ID
  2. Keys for the node to start right away
  3. Anything else, Terraform can return for zerotier_network, zerotier_identity and zerotier_member

Extra dummy run steps are very complicated for the the case of one-shot helm or terraform, deploy-to-kubernetes process

Is there a way to pre-setup or deduct interface name before node ever started? Can it be deducted with the code?

/var/lib/zerotier-one/devicemap requiring an interface name to be known already, which is not known ahead

E.g., some hints on ZT codebase?

Thank you

Looks like this, LinuxEthernetTap.cpp:

		uint64_t trial = 0; // incremented in the very unlikely event of a name collision with another network
		do {
			const uint64_t nwid40 = (nwid ^ (nwid >> 24)) + trial++;
			uint8_t tmp2[5];
			char tmp3[11];
			tmp2[0] = (uint8_t)((nwid40 >> 32) & 0xff);
			tmp2[1] = (uint8_t)((nwid40 >> 24) & 0xff);
			tmp2[2] = (uint8_t)((nwid40 >> 16) & 0xff);
			tmp2[3] = (uint8_t)((nwid40 >> 8) & 0xff);
			tmp2[4] = (uint8_t)(nwid40 & 0xff);
			tmp3[0] = 'z';
			tmp3[1] = 't';
			_base32_5_to_8(tmp2,tmp3 + 2);
			tmp3[10] = (char)0;
		} while (stat(procpath,&sbuf) == 0);

Is it the one?

Any way to make it more usable for the case in the topic ?

That looks like it. I don’t think anyone has made any type of calculator for it other than that implementation.

If you know the network ID ahead of time… you can get the interface name from any other node. It’s the same on all nodes per network ID.

Thank you,

Just checked,

They are different on different nodes.

At least, my OpnSense interface (FeeBSD 13.1) is different from Ubuntu, same ZT network.

It was the same on the same machine though, when I run it in container or on host (container with --network=host)

I think, it should just be an option in config file. E.g. interface="ztier0" So, if there any collision, it would just bail out on “stat” function above

Actually, my bad, too fast, too sleepy

I’ve misread, this is networkID from the left, not interface ID. And this is something deterministic

And it worked!

ah yeah, bsd has different names than linux
Not sure if devicemap works on bsd

1 Like

No problem with FreeBSD/Opnsense, this automation is for a common Linux only

So, devicemap solution works for me

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