[PR #6804] [client] Masquerade traffic to local route VIPs #29919

Open
opened 2026-08-05 08:09:24 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6804
Author: @CoderSufiyan
Created: 7/16/2026
Status: 🔄 Open

Base: mainHead: fix/issue-5851-local-vip-masquerade


📝 Commits (1)

  • 7884962 [client] Masquerade locally routed network traffic

📊 Changes

4 files changed (+46 additions, -11 deletions)

View changed files

📝 client/firewall/iptables/router_linux.go (+0 -1)
📝 client/firewall/iptables/router_linux_test.go (+8 -0)
📝 client/firewall/nftables/router_linux.go (+0 -10)
📝 client/firewall/nftables/router_linux_test.go (+38 -0)

📄 Description

Describe your changes

Allow marked routed traffic to reach the outbound masquerade target when Linux resolves its destination through the loopback interface. This covers same-host Keepalived and VRRP VIPs, which previously retained the remote NetBird source address because both iptables and nftables excluded all loopback-routed traffic.

The broad loopback exemption is no longer required for the eBPF WireGuard proxy because its exact loopback UDP flows are protected by the dedicated SetupEBPFProxyNoTrack raw-table rules.

Regression assertions cover both firewall backends.

Fixes #5851

Stack

  • This PR is independent

Checklist

  • I have performed a self-review of my own code
  • I have tested the changes locally
  • I have added or updated tests where applicable
  • I have checked for breaking changes

Documentation

  • Documentation is not needed

Validation

  • Linux amd64 cross-compilation with privileged tests for ./client/firewall/iptables
  • Linux amd64 cross-compilation with privileged tests for ./client/firewall/nftables
  • git diff --check

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Updated outbound network address translation so loopback-originated traffic is handled correctly.
    • Aligned firewall behavior across supported packet-filtering systems for more consistent outbound routing.
  • Tests

    • Added coverage confirming outbound masquerading rules are present and include eligible loopback traffic.
    • Improved validation of generated routing and NAT rules.

🔄 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/6804 **Author:** [@CoderSufiyan](https://github.com/CoderSufiyan) **Created:** 7/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/issue-5851-local-vip-masquerade` --- ### 📝 Commits (1) - [`7884962`](https://github.com/netbirdio/netbird/commit/78849626277720f3218f551b183cb16f18dd1cc4) [client] Masquerade locally routed network traffic ### 📊 Changes **4 files changed** (+46 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `client/firewall/iptables/router_linux.go` (+0 -1) 📝 `client/firewall/iptables/router_linux_test.go` (+8 -0) 📝 `client/firewall/nftables/router_linux.go` (+0 -10) 📝 `client/firewall/nftables/router_linux_test.go` (+38 -0) </details> ### 📄 Description ## Describe your changes Allow marked routed traffic to reach the outbound masquerade target when Linux resolves its destination through the loopback interface. This covers same-host Keepalived and VRRP VIPs, which previously retained the remote NetBird source address because both iptables and nftables excluded all loopback-routed traffic. The broad loopback exemption is no longer required for the eBPF WireGuard proxy because its exact loopback UDP flows are protected by the dedicated `SetupEBPFProxyNoTrack` raw-table rules. Regression assertions cover both firewall backends. ## Issue ticket number and link Fixes #5851 ## Stack - [x] This PR is independent ## Checklist - [x] I have performed a self-review of my own code - [x] I have tested the changes locally - [x] I have added or updated tests where applicable - [x] I have checked for breaking changes ## Documentation - [x] Documentation is **not needed** ## Validation - Linux amd64 cross-compilation with privileged tests for `./client/firewall/iptables` - Linux amd64 cross-compilation with privileged tests for `./client/firewall/nftables` - `git diff --check` <!-- codesmith:footer --> --- <a href="https://app.blacksmith.sh/netbirdio/codesmith/netbird/pr/6804"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with Codesmith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1786810082&installation_id=146802194&pr_number=6804&repository=netbirdio%2Fnetbird&return_to=https%3A%2F%2Fgithub.com%2Fnetbirdio%2Fnetbird%2Fpull%2F6804&signature=95c70ebce56764b23b7802fd5ab9f9a48f4241c4f7ec6eb9a778d50d90e7d916"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with Codesmith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"></picture></a> <sup>Need help on this PR? Tag <code>/codesmith</code> with what you need. Autofix is disabled.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Updated outbound network address translation so loopback-originated traffic is handled correctly. - Aligned firewall behavior across supported packet-filtering systems for more consistent outbound routing. - **Tests** - Added coverage confirming outbound masquerading rules are present and include eligible loopback traffic. - Improved validation of generated routing and NAT rules. <!-- 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 08:09:24 -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#29919