Add an option to force nftables usage #1642

Open
opened 2025-11-20 06:03:59 -05:00 by saavagebueno · 2 comments
Owner

Originally created by @jclds139 on GitHub (Feb 21, 2025).

Is your feature request related to a problem? Please describe.

When both iptables and nftables binaries are available on a system, netbird is choosing iptables, even though nftables if generally preferred (particularly over iptables-nft).

Describe the solution you'd like
I would think that nftables would be preferred when both are available, or at least that there should be an option to force nftables usage when the autodetection is failing.

Describe alternatives you've considered
There's an environment variable to force iptables usage (NB_SKIP_NFTABLES_CHECK), but no equivalent for prioritizing nftables.

Additional context

On current OpenWRT devices, this leads to some very strange bugs (similar to #2116 and #2530) when either legacy iptables or iptables-nft is present since the primary firewall uses nftables.

Originally created by @jclds139 on GitHub (Feb 21, 2025). **Is your feature request related to a problem? Please describe.** When both `iptables` and `nftables` binaries are available on a system, `netbird` is choosing `iptables`, even though `nftables` if generally preferred (particularly over `iptables-nft`). **Describe the solution you'd like** I would think that `nftables` would be preferred when both are available, or at least that there should be an option to force `nftables` usage when the autodetection is failing. **Describe alternatives you've considered** There's an environment variable to force `iptables` usage (`NB_SKIP_NFTABLES_CHECK`), but no equivalent for prioritizing `nftables`. **Additional context** On current OpenWRT devices, this leads to some very strange bugs (similar to #2116 and #2530) when either legacy `iptables` or `iptables-nft` is present since the primary firewall uses `nftables`.
saavagebueno added the feature-request label 2025-11-20 06:03:59 -05:00
Author
Owner

@wehagy commented on GitHub (Feb 21, 2025):

I tested what you mentioned here https://github.com/openwrt/packages/pull/26002#issuecomment-2670209028, when installing iptables on OpenWrt with netbird:

  • iptables is preferred and functions normally.
  • After installing sqm-scripts, everything works as expected.
  • However, when installing mwan3, netbird immediately breaks and cannot connect. I built locally to force nftables, but the result was the same. Once mwan3 is removed or stopped, netbird works again.
  • When defining the environment variables NB_DISABLE_CUSTOM_ROUTING=true and NB_SKIP_SOCKET_MARK=true, both netbird and mwan3 operate normally.

This suggests that the bug may stem from an incompatibility between mwan3 and netbird. When researching, I found that some users experienced similar issues with tailscale and mwan3. Although I'm not sure if it's directly relevant, here’s an excerpt from the official troubleshooting guide for tailscale:

On OpenWRT systems detected as running mwan3, Tailscale rules are installed at a lower priority for compatibility reasons. On such systems, ip rules are installed with priorities ranging 1300—1400 instead of 5200—5300.


Anyway, offering an option to force the use of nftables is beneficial on systems where it’s the default, such as OpenWrt. Furthermore, I might be talking nonsense here—sorry if that's the case—but having a build option to remove iptables from netbird could produce a smaller binary, which can be advantageous for embedded devices with limited storage.

@wehagy commented on GitHub (Feb 21, 2025): I tested what you mentioned here https://github.com/openwrt/packages/pull/26002#issuecomment-2670209028, when installing `iptables` on `OpenWrt` with `netbird`: - `iptables` is preferred and functions normally. - After installing `sqm-scripts`, everything works as expected. - However, when installing `mwan3`, `netbird` immediately breaks and cannot connect. I built locally to force `nftables`, but the result was the same. Once `mwan3` is removed or stopped, `netbird` works again. - When defining the environment variables `NB_DISABLE_CUSTOM_ROUTING=true` and `NB_SKIP_SOCKET_MARK=true`, both `netbird` and `mwan3` operate normally. This suggests that the bug may stem from an incompatibility between `mwan3` and `netbird`. When researching, I found that some users experienced similar issues with `tailscale` and `mwan3`. Although I'm not sure if it's directly relevant, here’s an excerpt from the official [troubleshooting](https://tailscale.com/kb/1023/troubleshooting#lan-traffic-prioritization-with-overlapping-subnet-routes) guide for `tailscale`: >On OpenWRT systems detected as running mwan3, Tailscale rules are installed at a lower priority for compatibility reasons. On such systems, ip rules are installed with priorities ranging 1300—1400 instead of 5200—5300. --- Anyway, offering an option to force the use of `nftables` is beneficial on systems where it’s the default, such as `OpenWrt`. Furthermore, I might be talking nonsense here—sorry if that's the case—but having a build option to remove `iptables` from `netbird` could produce a smaller binary, which can be advantageous for embedded devices with limited storage.
Author
Owner

@wehagy commented on GitHub (Apr 24, 2025):

Opened an issue at https://github.com/netbirdio/netbird/issues/3736 to address the incompatibility between packages.

@wehagy commented on GitHub (Apr 24, 2025): Opened an issue at https://github.com/netbirdio/netbird/issues/3736 to address the incompatibility between packages.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1642