[PR #5708] [MERGED] [client] Add dual-stack iptables manager with ip6tables support #23708

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5708
Author: @lixmal
Created: 3/26/2026
Status: Merged
Merged: 4/9/2026
Merged by: @lixmal

Base: client-ipv6-nftablesHead: client-ipv6-iptables


📝 Commits (10+)

  • b6bd2d6 Add dual-stack iptables manager with ip6tables support
  • 22c4be0 Fix CodeRabbit findings: anonymizer test, blockLanAccess v6 source, Windows cleanup accumulation
  • faef5a5 Add -4/-6 IP version flags to proxy debug ping, WASM ping, and SSH
  • 310b7dd Merge branch 'client-ipv6-nftables' into client-ipv6-iptables
  • 21ae32b Add IPv6 address parameter to TunAdapter.ConfigureInterface
  • 076bb32 Add best-effort rollback to iptables Init on partial failure
  • 5ccb00d Merge branch 'client-ipv6-nftables' into client-ipv6-iptables
  • 7053008 Merge remote-tracking branch 'origin/client-ipv6-nftables' into client-ipv6-iptables
  • ce5852b Merge remote-tracking branch 'origin/client-ipv6-nftables' into client-ipv6-iptables
  • 5c69fb0 Extract initChains to reduce Init cognitive complexity

📊 Changes

39 files changed (+1014 additions, -233 deletions)

View changed files

📝 client/android/client.go (+60 -19)
📝 client/android/route_command.go (+5 -2)
📝 client/anonymize/anonymize.go (+6 -0)
📝 client/cmd/ssh.go (+2 -2)
📝 client/cmd/ssh_test.go (+2 -2)
📝 client/firewall/iptables/acl_linux.go (+28 -3)
📝 client/firewall/iptables/manager_linux.go (+210 -26)
📝 client/firewall/iptables/router_linux.go (+50 -18)
📝 client/firewall/iptables/rule.go (+1 -0)
📝 client/firewall/iptables/state_linux.go (+30 -0)
📝 client/firewall/uspfilter/allow_netbird_windows.go (+38 -15)
📝 client/firewall/uspfilter/conntrack/common.go (+5 -2)
📝 client/firewall/uspfilter/filter.go (+2 -1)
📝 client/firewall/uspfilter/filter_test.go (+38 -0)
📝 client/firewall/uspfilter/localip_test.go (+0 -1)
📝 client/iface/configurer/usp.go (+1 -1)
📝 client/iface/device/adapter.go (+1 -1)
📝 client/iface/device/device_android.go (+1 -1)
📝 client/iface/wgproxy/bind/proxy.go (+13 -9)
📝 client/internal/debug/debug_test.go (+46 -3)

...and 19 more files

📄 Description

Describe your changes

iptables

  • Add parallel ipv6Client/aclMgr6/router6 in the iptables manager, dispatching operations by address family
  • Use -v6 suffix for ip6 ipset names (kernel ipsets are global, need family separation)
  • MSS clamping uses correct overhead per family (40 for v4, 60 for v6)
  • State cleanup creates v6 components even when current run has no IPv6 (previous run may have left state)

Misc

  • Fix blockLanAccess to use matching source family for IPv6 LAN prefixes
  • Accumulate errors in Windows firewall cleanup so v6 rule deletion isn't skipped on v4 failure
  • Fix shouldForward in USP filter for dual-stack address comparison
  • Fix anonymizer test assertions for updated v6 start address
  • Nil guard on fakeAddress for v6 peer address handling
  • SSH normalizeLocalHost("*") returns "" for dual-stack listening

Stacked on #5707.

Stack

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)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/594

Summary by CodeRabbit

  • New Features

    • Added IPv6 support to firewall rules, routing, and NAT operations.
    • Enabled IP version selection in diagnostic ping commands.
    • Added CIDR prefix support in IP anonymization.
    • Implemented dual-stack WireGuard interface configuration.
  • Bug Fixes

    • Improved port forwarding wildcard behavior for dual-stack networks.
    • Enhanced IPv4-mapped address handling in connection tracking.

🔄 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/netbirdio/netbird/pull/5708 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 3/26/2026 **Status:** ✅ Merged **Merged:** 4/9/2026 **Merged by:** [@lixmal](https://github.com/lixmal) **Base:** `client-ipv6-nftables` ← **Head:** `client-ipv6-iptables` --- ### 📝 Commits (10+) - [`b6bd2d6`](https://github.com/netbirdio/netbird/commit/b6bd2d667bbf67de558cffc65c1d86f1108ed65b) Add dual-stack iptables manager with ip6tables support - [`22c4be0`](https://github.com/netbirdio/netbird/commit/22c4be0c349c35cbcd6115d772244ecd25b52bce) Fix CodeRabbit findings: anonymizer test, blockLanAccess v6 source, Windows cleanup accumulation - [`faef5a5`](https://github.com/netbirdio/netbird/commit/faef5a57b3ab17c99e80ee222d98ece256899044) Add -4/-6 IP version flags to proxy debug ping, WASM ping, and SSH - [`310b7dd`](https://github.com/netbirdio/netbird/commit/310b7dd89bc8613411c384c0892593d968c3b77f) Merge branch 'client-ipv6-nftables' into client-ipv6-iptables - [`21ae32b`](https://github.com/netbirdio/netbird/commit/21ae32bb52f75c3b7a4bca1861f83b52987f8ad6) Add IPv6 address parameter to TunAdapter.ConfigureInterface - [`076bb32`](https://github.com/netbirdio/netbird/commit/076bb3292e47fb427ac98b1aa12e87bb46338f89) Add best-effort rollback to iptables Init on partial failure - [`5ccb00d`](https://github.com/netbirdio/netbird/commit/5ccb00df2cb227ca776fb01cd77905f5aa2d3877) Merge branch 'client-ipv6-nftables' into client-ipv6-iptables - [`7053008`](https://github.com/netbirdio/netbird/commit/70530081f28d40e7ec23ac15b9d837bc3d04bd45) Merge remote-tracking branch 'origin/client-ipv6-nftables' into client-ipv6-iptables - [`ce5852b`](https://github.com/netbirdio/netbird/commit/ce5852b9dd0da9c4af960f5d3895b0ac0c741836) Merge remote-tracking branch 'origin/client-ipv6-nftables' into client-ipv6-iptables - [`5c69fb0`](https://github.com/netbirdio/netbird/commit/5c69fb0ce758d5b3201de9c670e3c608f91e61c5) Extract initChains to reduce Init cognitive complexity ### 📊 Changes **39 files changed** (+1014 additions, -233 deletions) <details> <summary>View changed files</summary> 📝 `client/android/client.go` (+60 -19) 📝 `client/android/route_command.go` (+5 -2) 📝 `client/anonymize/anonymize.go` (+6 -0) 📝 `client/cmd/ssh.go` (+2 -2) 📝 `client/cmd/ssh_test.go` (+2 -2) 📝 `client/firewall/iptables/acl_linux.go` (+28 -3) 📝 `client/firewall/iptables/manager_linux.go` (+210 -26) 📝 `client/firewall/iptables/router_linux.go` (+50 -18) 📝 `client/firewall/iptables/rule.go` (+1 -0) 📝 `client/firewall/iptables/state_linux.go` (+30 -0) 📝 `client/firewall/uspfilter/allow_netbird_windows.go` (+38 -15) 📝 `client/firewall/uspfilter/conntrack/common.go` (+5 -2) 📝 `client/firewall/uspfilter/filter.go` (+2 -1) 📝 `client/firewall/uspfilter/filter_test.go` (+38 -0) 📝 `client/firewall/uspfilter/localip_test.go` (+0 -1) 📝 `client/iface/configurer/usp.go` (+1 -1) 📝 `client/iface/device/adapter.go` (+1 -1) 📝 `client/iface/device/device_android.go` (+1 -1) 📝 `client/iface/wgproxy/bind/proxy.go` (+13 -9) 📝 `client/internal/debug/debug_test.go` (+46 -3) _...and 19 more files_ </details> ### 📄 Description ## Describe your changes ### iptables - Add parallel `ipv6Client`/`aclMgr6`/`router6` in the iptables manager, dispatching operations by address family - Use `-v6` suffix for ip6 ipset names (kernel ipsets are global, need family separation) - MSS clamping uses correct overhead per family (40 for v4, 60 for v6) - State cleanup creates v6 components even when current run has no IPv6 (previous run may have left state) ### Misc - Fix `blockLanAccess` to use matching source family for IPv6 LAN prefixes - Accumulate errors in Windows firewall cleanup so v6 rule deletion isn't skipped on v4 failure - Fix `shouldForward` in USP filter for dual-stack address comparison - Fix anonymizer test assertions for updated v6 start address - Nil guard on `fakeAddress` for v6 peer address handling - SSH `normalizeLocalHost("*")` returns `""` for dual-stack listening Stacked on #5707. ## Issue ticket number and link ## Stack - #5631 - #5675 - #5686 - #5687 - #5688 - #5706 - #5707 - #5708 :point_left: ### 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) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/594 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added IPv6 support to firewall rules, routing, and NAT operations. * Enabled IP version selection in diagnostic ping commands. * Added CIDR prefix support in IP anonymization. * Implemented dual-stack WireGuard interface configuration. * **Bug Fixes** * Improved port forwarding wildcard behavior for dual-stack networks. * Enhanced IPv4-mapped address handling in connection tracking. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 06:07:45 -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#23708