Optional random node suffixes. #317

Closed
opened 2025-12-29 01:26:47 +01:00 by adam · 2 comments
Owner

Originally created by @shanna on GitHub (Aug 25, 2022).

The random node suffixes introduced in 0.16.0 mean machines onboarded with preauth keys end up on random MagicDNS hostnames. My use case is I generate preauth keys and unique hostnames for devices during provisioning programatically and I'd like for my software to be able to resolve the hostnames later within the namespace's subdomain.

I've got a branch here that implements the change though I thought I better create a ticket first before submitting a PR since this may generate some discussion.

  • I think suffixes should be off by default but YMMV. It does revert the new default prefixes introduced in 0.16.0 and I have no idea what Tailscale does by default. 🤷
  • The other ways this could be solved is by setting a node name in advance when you create a preauth key via the API or by honouring the --hostname tailscale cli flag? No idea how difficult these options would be to implement but I'm happy to have a crack if you'd rather not introduce another configuration variable.
Originally created by @shanna on GitHub (Aug 25, 2022). <!-- Headscale is a multinational community across the globe. Our common language is English. Please consider raising the feature request in this language. --> The random node suffixes introduced in 0.16.0 mean machines onboarded with preauth keys end up on random MagicDNS hostnames. My use case is I generate preauth keys and unique hostnames for devices during provisioning programatically and I'd like for my software to be able to resolve the hostnames later within the namespace's subdomain. I've got a branch [here](https://github.com/shanna/headscale/tree/feature-optional-hostname-suffix) that implements the change though I thought I better create a ticket first before submitting a PR since this may generate some discussion. * I think suffixes should be off by default but YMMV. It does revert the new default prefixes introduced in 0.16.0 and I have no idea what Tailscale does by default. 🤷 * The other ways this could be solved is by setting a node name in advance when you create a preauth key via the API or by honouring the `--hostname` tailscale cli flag? No idea how difficult these options would be to implement but I'm happy to have a crack if you'd rather not introduce another configuration variable. <!-- A clear and precise description of what new or changed feature you want. --> <!-- Please include the reason, why you would need the feature. E.g. what problem does it solve? Or which workflow is currently frustrating and will be improved by this? -->
adam added the enhancement label 2025-12-29 01:26:47 +01:00
adam closed this issue 2025-12-29 01:26:47 +01:00
Author
Owner

@kradalby commented on GitHub (Aug 30, 2022):

This change was introduced as we had behaviour that would put the MagicDNS in a conflicting state, two or more machines in could try to have the same DNS, while it might not be the optimal solution, it is needed to be implemented over a broken configuration.

It isn't sufficient to have an option to revert the behaviour as it will allow users to end up in a state with unexpected and indeterministic behaviour. The core argument for this is support load, and potential other weirdness.

I think improving the behaviour would be the way to go.
My initial thought would be that when ever a machine is registered/updated/renamed, the database is checked for the machine + namespace combination to verify it is unique, if it is unique, the suffix is not applied, effectively restoring the behaviour in most of the cases.

@kradalby commented on GitHub (Aug 30, 2022): This change was introduced as we had behaviour that would put the MagicDNS in a conflicting state, two or more machines in could try to have the same DNS, while it might not be the optimal solution, it is needed to be implemented over a broken configuration. It isn't sufficient to have an option to revert the behaviour as it will allow users to end up in a state with unexpected and indeterministic behaviour. The core argument for this is support load, and potential other weirdness. I think _improving_ the behaviour would be the way to go. My initial thought would be that when ever a machine is registered/updated/renamed, the database is checked for the machine + namespace combination to verify it is unique, if it is unique, the suffix is _not_ applied, effectively restoring the behaviour in most of the cases.
Author
Owner

@shanna commented on GitHub (Aug 31, 2022):

OK. I've created a new PR that only applies a suffix if the given name collides with another machine in the same namespace.

@shanna commented on GitHub (Aug 31, 2022): OK. I've created a new PR that only applies a suffix if the given name collides with another machine in the same namespace.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#317