[Feature] make it possible to read extra_records from file #866

Closed
opened 2025-12-29 02:25:01 +01:00 by adam · 3 comments
Owner

Originally created by @kradalby on GitHub (Nov 29, 2024).

Use case

When use_username_in_magic_dns is removed, there will be a gap where DNS entries might not be available for some configuration.

A possible workaround is to generate these entries and put them in extra_records and generate them based on your headscale. See https://github.com/juanfont/headscale/issues/1369#issuecomment-2339901185 for more information.

Description

To facilitate this use case (and others where you want to inject dns entries programmatically, we should add the ability to consume extra_records from a JSON file.

For example, this will allow administrators to use headscale commands as part of a script to generate a JSON file by looping over the entries in the host list and create entries containing the username.

Contribution

  • I can write the design doc for this feature
  • I can contribute this feature

How can it be implemented?

Let us create a new config option like extra_records_path or maybe paths, which sets up a file watcher reading the DNS entries on change.
It should hash the file and check against the old hash to make sure we dont sent any updates if the file or content has not changed.

If the content has changed, propagate it to the nodes in the tailnet with our update mechanism, see if we can have a fastpath that only sends DNS updates.

Originally created by @kradalby on GitHub (Nov 29, 2024). ### Use case When `use_username_in_magic_dns` is removed, there will be a gap where DNS entries might not be available for some configuration. A possible workaround is to generate these entries and put them in `extra_records` and generate them based on your headscale. See https://github.com/juanfont/headscale/issues/1369#issuecomment-2339901185 for more information. ### Description To facilitate this use case (and others where you want to inject dns entries programmatically, we should add the ability to consume extra_records from a JSON file. For example, this will allow administrators to use `headscale` commands as part of a script to generate a JSON file by looping over the entries in the host list and create entries containing the username. ### Contribution - [X] I can write the design doc for this feature - [X] I can contribute this feature ### How can it be implemented? Let us create a new config option like `extra_records_path` or maybe paths, which sets up a file watcher reading the DNS entries on change. It should hash the file and check against the old hash to make sure we dont sent any updates if the file or content has not changed. If the content has changed, propagate it to the nodes in the tailnet with our update mechanism, see if we can have a fastpath that only sends DNS updates.
adam added the enhancementDNS labels 2025-12-29 02:25:01 +01:00
adam closed this issue 2025-12-29 02:25:02 +01:00
Author
Owner

@nikp123 commented on GitHub (Dec 4, 2024):

Furthermore for people who rely on this (as stated) incorrect behavior:
Is it a problem to make headscale itself invoke a script for generating DNS records upon a new client being registered/deregistered to the server? This would potentially reduce administration overhead and possible mistakes as well. A cron would be also fine, but this seems nicer.

@nikp123 commented on GitHub (Dec 4, 2024): Furthermore for people who rely on this (as stated) *incorrect* behavior: Is it a problem to make headscale itself invoke a script for generating DNS records upon a new client being registered/deregistered to the server? This would potentially reduce administration overhead and possible mistakes as well. A cron would be also fine, but this seems nicer.
Author
Owner

@kradalby commented on GitHub (Dec 5, 2024):

It would be possible to make a feature like that, but it would rely on a lot more logic and change, kind of similar to webhooks (https://github.com/juanfont/headscale/issues/1543), which is on the table, but it is not really practical to block this feature on that. We have not really started to think about how that would be implemented and I think its a significantly bigger undertaking.

@kradalby commented on GitHub (Dec 5, 2024): It would be possible to make a feature like that, but it would rely on a lot more logic and change, kind of similar to webhooks (https://github.com/juanfont/headscale/issues/1543), which is on the table, but it is not really practical to block this feature on that. We have not really started to think about how that would be implemented and I think its a significantly bigger undertaking.
Author
Owner

@nikp123 commented on GitHub (Dec 5, 2024):

It would be possible to make a feature like that, but it would rely on a lot more logic and change, kind of similar to webhooks (#1543), which is on the table, but it is not really practical to block this feature on that.

Webhooks seem like a fine solution as well. Thanks for the information.

@nikp123 commented on GitHub (Dec 5, 2024): > It would be possible to make a feature like that, but it would rely on a lot more logic and change, kind of similar to webhooks (#1543), which is on the table, but it is not really practical to block this feature on that. Webhooks seem like a fine solution as well. Thanks for the information.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#866