[PR #1459] Add support for IPv6 networks (on Linux clients) #17075

Open
opened 2026-08-05 04:06:54 -04:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/1459

State: closed
Merged: Yes


Describe your changes

This PR adds some initial support for assigning IPv6 addresses to hosts inside of the wireguard network.
For now, only Linux using the kernel module and nftables as the firewall implementation is supported.

Note for reviewers:
I have been working on this on and off for a couple of months and had to merge in a lot of upstream changes, it's probably easier to review the final version instead of going through each commit separately. 😅

Notes on address assignment

On network creation (or assignment of the first IPv6 address for existing networks), a random /64 prefix in the ULA range is generated, which will be used for devices on the network.
On enabling IPv6 on supported hosts, a random address will be generated for the host.
Disabling and then re-enabling IPv6 results in a new IPv6 address being generated.

Testing

I have tested this PR on the following clients:

  • Linux (both using kernel wireguard, which supports IPv6, and tun, which does not)
  • Windows (which does not support IPv6)
  • Version 0.25.2 on linux combined with the management server built from this branch

Unfortunately, I don't have the environment set up and/or lack the devices to test other operating systems.

How to test:

  1. Spin up an instance of the management server from this branch, as well as an instance of the frontend with the necessary changes (see the corresponding PR in the dashboard repository).
  2. Build and run the netbird client from this branch, add it to the management server.
  3. Open the frontend, and enable ipv6 in the peer settings.
    grafik
  4. Alternatively, leave the peer IPv6 setting at "Inherit from Groups" (the default) and instead enable IPv6 for all hosts in a group in the group settings.
    grafik
  5. Look at the Wireguard interface/firewall/route configuration on the clients, test pinging the devices using IPv6, etc.

Known issues and TODOs

  • Update dashboard changes to work with new dashboard versions
  • Integrate with Groups (allow enabling IPv6 for an entire Group at once)
  • During development, i have seen problems when updating a peer from a non-IPv6-supported version to an IPv6-supported version (other peers do not establish connections properly until they are restarted)
    • unsure if this is still the case or if other changes i made fixed that by now haven't seen this problem during my testing anymore
  • When the nftables-backend is used but IPv6 is disabled by the management server, we still create an (empty) firewall table
    • maybe problematic if the peer does not support IPv6 at all (disabled kernel support, etc.)
  • Improve handling of IPv6 routes
    • Prevent creation of IPv6 routes with routing peers or groups that have IPv6 disabled
      • Disabling for groups might be too inflexible, you might actually want to use an existing group with IPv6 disabled for an IPv6 route, if some of the hosts have IPv6 enabled through other means.
    • Disallow disabling IPv6 for peer if it is acting as a routing peer for an IPv6 route
      • I instead opted for the approach listed in the next bullet point
    • Automatically disable all IPv6 routes if IPv6 is disabled for a peer.
      • The "Inherit from Groups" setting should be renamed to "Auto" and also automatically enable IPv6 if peer is IPv6 routing peer.
    • Disable routing peers/groups if they no longer support IPv6 (e.g. because of a downgrade)
    • Ensure that only IPv6-enabled group members are distributed as routing peers if group is used as routing peer
      • (unsure if this is already the case)
  • Improve handling of IPv6 Nameservers
    • Distribute IPv6 Nameserver IPs to IPv6 enabled peers only
  • Fix compilation issues on non-linux targets caused by my last changes
  • Write some more test cases, make sure the existing ones all pass
    • Fix existing test cases
    • Write test cases for client
    • Write test cases for management server
  • Documentation

Adding support for other operating systems/Linux with iptables/uspfilter is probably something better suited for a separate PR, considering the current size of this one.
I have done some preliminary testing with enabling IPv6 on Windows in one of the older commits - assignment of IPv6 addresses is pretty trivial. However, due to some issue (probably routing), I wasn't able to ping other peers, which is why I did not include it for this PR.

Resolves (partially) #1167 and #46

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/1459 **State:** closed **Merged:** Yes --- ## Describe your changes This PR adds some initial support for assigning IPv6 addresses to hosts inside of the wireguard network. For now, only Linux using the kernel module and nftables as the firewall implementation is supported. **Note for reviewers:** I have been working on this on and off for a couple of months and had to merge in a lot of upstream changes, it's probably easier to review the final version instead of going through each commit separately. :sweat_smile: ### Notes on address assignment On network creation (or assignment of the first IPv6 address for existing networks), a random /64 prefix in the ULA range is generated, which will be used for devices on the network. On enabling IPv6 on supported hosts, a random address will be generated for the host. Disabling and then re-enabling IPv6 results in a new IPv6 address being generated. ### Testing I have tested this PR on the following clients: - Linux (both using kernel wireguard, which supports IPv6, and tun, which does not) - Windows (which does not support IPv6) - Version 0.25.2 on linux combined with the management server built from this branch Unfortunately, I don't have the environment set up and/or lack the devices to test other operating systems. How to test: 1. Spin up an instance of the management server from this branch, as well as an instance of the frontend with the necessary changes (see the corresponding [PR in the dashboard repository](https://github.com/netbirdio/dashboard/pull/314)). 2. Build and run the netbird client from this branch, add it to the management server. 3. Open the frontend, and enable ipv6 in the peer settings. ![grafik](https://github.com/netbirdio/netbird/assets/13301997/c48f38bf-3461-4c02-bc40-f069f805dd0c) 4. Alternatively, leave the peer IPv6 setting at "Inherit from Groups" (the default) and instead enable IPv6 for all hosts in a group in the group settings. ![grafik](https://github.com/netbirdio/netbird/assets/13301997/7164e5ae-d01d-4df2-86b3-01d9ccb03171) 5. Look at the Wireguard interface/firewall/route configuration on the clients, test pinging the devices using IPv6, etc. ### Known issues and TODOs - [x] Update dashboard changes to work with new dashboard versions - [x] Integrate with Groups (allow enabling IPv6 for an entire Group at once) - [x] During development, i have seen problems when updating a peer from a non-IPv6-supported version to an IPv6-supported version (other peers do not establish connections properly until they are restarted) - ~~unsure if this is still the case or if other changes i made fixed that by now~~ haven't seen this problem during my testing anymore - [x] When the nftables-backend is used but IPv6 is disabled by the management server, we still create an (empty) firewall table - maybe problematic if the peer does not support IPv6 at all (disabled kernel support, etc.) - [x] Improve handling of IPv6 routes - [x] Prevent creation of IPv6 routes with routing peers ~~or groups~~ that have IPv6 disabled - Disabling for groups might be too inflexible, you might actually want to use an existing group with IPv6 disabled for an IPv6 route, if some of the hosts have IPv6 enabled through other means. - [x] ~~Disallow disabling IPv6 for peer if it is acting as a routing peer for an IPv6 route~~ - I instead opted for the approach listed in the next bullet point - [x] Automatically disable all IPv6 routes if IPv6 is disabled for a peer. - [x] The "Inherit from Groups" setting should be renamed to "Auto" and also automatically enable IPv6 if peer is IPv6 routing peer. - [x] Disable routing peers/groups if they no longer support IPv6 (e.g. because of a downgrade) - [x] Ensure that only IPv6-enabled group members are distributed as routing peers if group is used as routing peer - (unsure if this is already the case) - [x] Improve handling of IPv6 Nameservers - [x] Distribute IPv6 Nameserver IPs to IPv6 enabled peers only - [x] Fix compilation issues on non-linux targets caused by my last changes - [x] Write some more test cases, make sure the existing ones all pass - [x] Fix existing test cases - [x] Write test cases for client - Note that due to the [lack of IPv6 support on GitHub Actions runners](https://github.com/actions/runner-images/issues/668#issuecomment-624080758), the IPv6 tests will be skipped there. Make sure to run them locally in order to verify that they pass. - [x] Write test cases for management server - [x] Documentation - can be found in netbirdio/docs#165 Adding support for other operating systems/Linux with iptables/uspfilter is probably something better suited for a separate PR, considering the current size of this one. I have done some preliminary testing with enabling IPv6 on Windows in one of the older commits - assignment of IPv6 addresses is pretty trivial. However, due to some issue (probably routing), I wasn't able to ping other peers, which is why I did not include it for this PR. ## Issue ticket number and link Resolves (partially) #1167 and #46 ### Checklist - [ ] ~~Is it a bug fix~~ - [ ] ~~Is a typo/documentation fix~~ - [x] Is a feature enhancement - [ ] ~~It is a refactor~~ - [x] Created tests that fail without the change (if possible) - [x] Extended the README / documentation, if necessary
saavagebueno added the pull-request label 2026-08-05 04:06:54 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#17075