[PR #208] [MERGED] Support for IPv6 prefixes in namespaces #1320

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

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/208
Author: @enoperm
Created: 10/31/2021
Status: Merged
Merged: 1/30/2022
Merged by: @kradalby

Base: mainHead: ipv6


📝 Commits (10+)

  • 46cdce0 Do not assume IPv4 during address generation
  • 7ec8346 Do not assume IPv4 during Tailscale node construction
  • 8b40343 Add multiple IP prefixes support to ProtoBuf schema
  • 3a3aecb Regenerate files based on ProtoBuf schema.
  • 1a6e5d8 Add support for multiple IP prefixes
  • 115d0cb dns: IPv6 roots generation
  • d35fb8b integration-test: add IPv6 prefix to configuration
  • a32175f PollNetMapHandler: refactor with chan lifetimes in mind
  • 8f632e9 machine: isOutdated: handle machines without LastSuccefulUpdate set
  • ed39b91 Dockerfiles: specify origin registry explicitly

📊 Changes

36 files changed (+865 additions, -528 deletions)

View changed files

📝 CHANGELOG.md (+8 -0)
📝 Dockerfile (+1 -1)
📝 Dockerfile.alpine (+2 -2)
📝 Dockerfile.debug (+1 -1)
📝 Dockerfile.tailscale (+1 -1)
📝 Makefile (+1 -1)
📝 acls.go (+3 -3)
📝 acls_test.go (+26 -24)
📝 api.go (+8 -7)
📝 app.go (+2 -4)
📝 app_test.go (+3 -1)
📝 cli_test.go (+6 -4)
📝 cmd/headscale/cli/nodes.go (+3 -2)
📝 cmd/headscale/cli/utils.go (+48 -3)
📝 config-example.yaml (+7 -0)
📝 dns.go (+75 -7)
📝 dns_test.go (+50 -12)
📝 gen/go/headscale/v1/device.pb.go (+1 -1)
📝 gen/go/headscale/v1/headscale.pb.go (+1 -1)
📝 gen/go/headscale/v1/machine.pb.go (+117 -117)

...and 16 more files

📄 Description

I'm sending an MR to initiate a discussion about this initial implementation.

I have found that specifying an IPv6 prefix for ip_prefix caused the Headscale server to crash, because getAvailableIP assumed an IPv4 address by calling As4().

While I was at it, I also tidied up address generation a bit, because the comment within was inaccurate (a network/broadcast address is one where the host parts of the address are all zero/one bits, not ones that end with eights consecutive zero/one bits), and if I interpret the netaddr API reference correctly, IsZero() and IsLoopback() should never return true for the same address, so I assume the use of && probably had been a typo here.

I also found that machine.go also assumed an IPv4 representation and sent /32 routes to nodes, which tailscaled refused to use, even though tailscale ping managed to resolve the correct destination node.

These changes were enough to ICMPv6 ping working both against namespace addresses, as well as advertised IPv6 routes. As far as I can see, the changes did not break any of the established tests that use IPv4, but I have not yet added any IPv6 specific test coverage - If I read the code correctly, there is a single unit under test preconfigured with an IPv4 prefix, and I'm not sure about the optimal way to handle the situation.

I have also separately tested with the default IPv4 prefix as well and things seem to still work that way.
I'm not sure why yet, but I was only able to access IPv4 advertised routes when I also used an IPv4 prefix for the namespace, and only able to access IPv6 advertised routes with an IPv6 prefix configured for the namespace. Accessing IPv4 advertised routes from an IPv6 prefix or the other way around does not seem to work, and I have yet to perceive any error messages anywhere, so far I can only observe the lack of packets.


🔄 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/208 **Author:** [@enoperm](https://github.com/enoperm) **Created:** 10/31/2021 **Status:** ✅ Merged **Merged:** 1/30/2022 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `ipv6` --- ### 📝 Commits (10+) - [`46cdce0`](https://github.com/juanfont/headscale/commit/46cdce00af6f123576d572fe8facfa93db7b79a2) Do not assume IPv4 during address generation - [`7ec8346`](https://github.com/juanfont/headscale/commit/7ec834617959025bb3294d6dadb2ee3b070e62e0) Do not assume IPv4 during Tailscale node construction - [`8b40343`](https://github.com/juanfont/headscale/commit/8b4034327776c2d1010d34387e4d237c7d84fedb) Add multiple IP prefixes support to ProtoBuf schema - [`3a3aecb`](https://github.com/juanfont/headscale/commit/3a3aecb7742d94d7747a44eb31ae634dbb83b189) Regenerate files based on ProtoBuf schema. - [`1a6e5d8`](https://github.com/juanfont/headscale/commit/1a6e5d8770ddc2761c931ae9d6f704e80e9dc9bc) Add support for multiple IP prefixes - [`115d0cb`](https://github.com/juanfont/headscale/commit/115d0cbe855ef526148ba0191ca2df14106779c1) dns: IPv6 roots generation - [`d35fb8b`](https://github.com/juanfont/headscale/commit/d35fb8bba0a34c96055f77072b087d14e50f58ae) integration-test: add IPv6 prefix to configuration - [`a32175f`](https://github.com/juanfont/headscale/commit/a32175f791a3f1e5ffbe9a6db05f6f74b0a2143a) PollNetMapHandler: refactor with chan lifetimes in mind - [`8f632e9`](https://github.com/juanfont/headscale/commit/8f632e9062cd8b8c29db973fcb14e9e4925c1428) machine: isOutdated: handle machines without LastSuccefulUpdate set - [`ed39b91`](https://github.com/juanfont/headscale/commit/ed39b91f717e06e9b76f6dba8c68ba0d0b0b179a) Dockerfiles: specify origin registry explicitly ### 📊 Changes **36 files changed** (+865 additions, -528 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+8 -0) 📝 `Dockerfile` (+1 -1) 📝 `Dockerfile.alpine` (+2 -2) 📝 `Dockerfile.debug` (+1 -1) 📝 `Dockerfile.tailscale` (+1 -1) 📝 `Makefile` (+1 -1) 📝 `acls.go` (+3 -3) 📝 `acls_test.go` (+26 -24) 📝 `api.go` (+8 -7) 📝 `app.go` (+2 -4) 📝 `app_test.go` (+3 -1) 📝 `cli_test.go` (+6 -4) 📝 `cmd/headscale/cli/nodes.go` (+3 -2) 📝 `cmd/headscale/cli/utils.go` (+48 -3) 📝 `config-example.yaml` (+7 -0) 📝 `dns.go` (+75 -7) 📝 `dns_test.go` (+50 -12) 📝 `gen/go/headscale/v1/device.pb.go` (+1 -1) 📝 `gen/go/headscale/v1/headscale.pb.go` (+1 -1) 📝 `gen/go/headscale/v1/machine.pb.go` (+117 -117) _...and 16 more files_ </details> ### 📄 Description I'm sending an MR to initiate a discussion about this initial implementation. I have found that specifying an IPv6 prefix for `ip_prefix` caused the Headscale server to crash, because `getAvailableIP` assumed an IPv4 address by calling `As4()`. While I was at it, I also tidied up address generation a bit, because the comment within was inaccurate (a network/broadcast address is one where the host parts of the address are all zero/one bits, not ones that end with eights consecutive zero/one bits), and if I interpret the `netaddr` API reference correctly, `IsZero()` and `IsLoopback()` should never return true for the same address, so I assume the use of `&&` probably had been a typo here. I also found that `machine.go` also assumed an IPv4 representation and sent `/32` routes to nodes, which `tailscaled` refused to use, even though `tailscale ping` managed to resolve the correct destination node. These changes were enough to ICMPv6 ping working both against namespace addresses, as well as advertised IPv6 routes. As far as I can see, the changes did not break any of the established tests that use IPv4, but I have not yet added any IPv6 specific test coverage - If I read the code correctly, there is a single unit under test preconfigured with an IPv4 prefix, and I'm not sure about the optimal way to handle the situation. I have also separately tested with the default IPv4 prefix as well and things seem to still work that way. I'm not sure why yet, but I was only able to access IPv4 advertised routes when I also used an IPv4 prefix for the namespace, and only able to access IPv6 advertised routes with an IPv6 prefix configured for the namespace. Accessing IPv4 advertised routes from an IPv6 prefix or the other way around does not seem to work, and I have yet to perceive any error messages anywhere, so far I can only observe the lack of packets. --- <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 02:29:40 +01:00
adam closed this issue 2025-12-29 02:29:40 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1320