[PR #1515] [CLOSED] Custom machine address #2159

Closed
opened 2025-12-29 03:20:01 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/1515
Author: @lembq
Created: 7/25/2023
Status: Closed

Base: mainHead: custom-machine-address


📝 Commits (2)

  • 5cdc6bf [ASSIGN CUSTOM IP] register new machine with custom IPv4 address
  • cd33090 [CUSTOM IP gen] the newly generated protos

📊 Changes

13 files changed (+118 additions, -6 deletions)

View changed files

📝 cmd/headscale/cli/nodes.go (+11 -1)
📝 docs/running-headscale-container.md (+6 -0)
📝 docs/running-headscale-linux-manual.md (+6 -0)
📝 docs/running-headscale-linux.md (+6 -0)
📝 docs/running-headscale-openbsd.md (+6 -0)
📝 gen/go/headscale/v1/machine.pb.go (+11 -2)
📝 gen/openapiv2/headscale/v1/headscale.swagger.json (+6 -0)
📝 hscontrol/auth.go (+1 -0)
📝 hscontrol/db/addresses.go (+18 -0)
📝 hscontrol/db/machine.go (+43 -3)
📝 hscontrol/grpcv1.go (+2 -0)
📝 hscontrol/oidc.go (+1 -0)
📝 proto/headscale/v1/machine.proto (+1 -0)

📄 Description

We wanted to assign a custom ip address to our machines on the tailscale network. After a quick google search we found a the request for this enhancement (#1455 ). I implemented the functionality to be able to assign a specific IPv4 address when registering a machine. There is a new flag called --ip which can be set optionally. An example can be seen in the documentation. Without setting this flag the registration will work the same way as previously (the sequentially next ip will be assigned). An already used ip cannot be choosen. An ip address that is outside the configured prefix range is also not possible.

I tested this new feature locally with docker and one node but I will also test it on a larger scale in the next few days.

No OIDC and IPv6 support yet to keep the changes as small as possible.

The outcommented part in machine.go is just one way of assigning an IPv6 address as well. I did not find it sophisticated enough to use so I only support IPv4 yet. I would appreciate any ideas on how I could make that part robust because this design decision is crucial for the future developement.

I welcome any feedback or suggestions from the community and fellow contributors. Your opinions and insights are greatly appreciated as I strive to improve and learn.

  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/1515 **Author:** [@lembq](https://github.com/lembq) **Created:** 7/25/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `custom-machine-address` --- ### 📝 Commits (2) - [`5cdc6bf`](https://github.com/juanfont/headscale/commit/5cdc6bfcbe47d94871dbdee625240ba21782f392) [ASSIGN CUSTOM IP] register new machine with custom IPv4 address - [`cd33090`](https://github.com/juanfont/headscale/commit/cd33090b5ded78c2a2765298641598a7d9013263) [CUSTOM IP gen] the newly generated protos ### 📊 Changes **13 files changed** (+118 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `cmd/headscale/cli/nodes.go` (+11 -1) 📝 `docs/running-headscale-container.md` (+6 -0) 📝 `docs/running-headscale-linux-manual.md` (+6 -0) 📝 `docs/running-headscale-linux.md` (+6 -0) 📝 `docs/running-headscale-openbsd.md` (+6 -0) 📝 `gen/go/headscale/v1/machine.pb.go` (+11 -2) 📝 `gen/openapiv2/headscale/v1/headscale.swagger.json` (+6 -0) 📝 `hscontrol/auth.go` (+1 -0) 📝 `hscontrol/db/addresses.go` (+18 -0) 📝 `hscontrol/db/machine.go` (+43 -3) 📝 `hscontrol/grpcv1.go` (+2 -0) 📝 `hscontrol/oidc.go` (+1 -0) 📝 `proto/headscale/v1/machine.proto` (+1 -0) </details> ### 📄 Description We wanted to assign a custom ip address to our machines on the tailscale network. After a quick google search we found a the request for this enhancement (#1455 ). I implemented the functionality to be able to assign a specific IPv4 address when registering a machine. There is a new flag called --ip which can be set optionally. An example can be seen in the documentation. Without setting this flag the registration will work the same way as previously (the sequentially next ip will be assigned). An already used ip cannot be choosen. An ip address that is outside the configured prefix range is also not possible. I tested this new feature locally with docker and one node but I will also test it on a larger scale in the next few days. No OIDC and IPv6 support yet to keep the changes as small as possible. The outcommented part in machine.go is just one way of assigning an IPv6 address as well. I did not find it sophisticated enough to use so I only support IPv4 yet. I would appreciate any ideas on how I could make that part robust because this design decision is crucial for the future developement. I welcome any feedback or suggestions from the community and fellow contributors. Your opinions and insights are greatly appreciated as I strive to improve and learn. <!-- Headscale is "Open Source, acknowledged contribution", this means that any contribution will have to be discussed with the Maintainers before being submitted. This model has been chosen to reduce the risk of burnout by limiting the maintenance overhead of reviewing and validating third-party code. Headscale is open to code contributions for bug fixes without discussion. If you find mistakes in the documentation, please submit a fix to the documentation. --> <!-- Please tick if the following things apply. You… --> - [x] read the [CONTRIBUTING guidelines](README.md#contributing) - [x] raised a GitHub issue or discussed it on the projects chat beforehand - [ ] added unit tests - [ ] added integration tests - [x] updated documentation if needed - [ ] updated CHANGELOG.md <!-- If applicable, please reference the issue using `Fixes #XXX` and add tests to cover your new code. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 03:20:01 +01:00
adam closed this issue 2025-12-29 03:20:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2159