[PR #2298] [MERGED] Add network route access control on client #16942

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/2298
Author: @lixmal
Created: 7/22/2024
Status: Merged
Merged: 8/6/2024
Merged by: @lixmal

Base: feature/network-route-access-controlHead: feature/network-route-access-control-client


📝 Commits (7)

📊 Changes

26 files changed (+1783 additions, -1600 deletions)

View changed files

📝 client/firewall/iface.go (+3 -1)
📝 client/firewall/iptables/acl_linux.go (+22 -144)
📝 client/firewall/iptables/manager_linux.go (+34 -15)
📝 client/firewall/iptables/manager_linux_test.go (+27 -27)
📝 client/firewall/iptables/router_linux.go (+183 -207)
📝 client/firewall/iptables/router_linux_test.go (+150 -69)
📝 client/firewall/manager/firewall.go (+27 -13)
📝 client/firewall/manager/routerpair.go (+10 -4)
📝 client/firewall/nftables/acl_linux.go (+38 -464)
📝 client/firewall/nftables/manager_linux.go (+53 -20)
📝 client/firewall/nftables/manager_linux_test.go (+20 -19)
client/firewall/nftables/route_linux.go (+0 -431)
client/firewall/nftables/router_linux.go (+580 -0)
📝 client/firewall/nftables/router_linux_test.go (+309 -80)
📝 client/firewall/test/cases_linux.go (+11 -9)
📝 client/firewall/uspfilter/uspfilter.go (+34 -11)
📝 client/firewall/uspfilter/uspfilter_test.go (+10 -10)
client/internal/acl/id/id.go (+26 -0)
📝 client/internal/acl/manager.go (+142 -34)
📝 client/internal/acl/manager_test.go (+13 -13)

...and 6 more files

📄 Description

Describe your changes

Add:

  • Methods to set up forward rules for routed traffic (network ACLs) according to the network map
    Modify:
  • Apply ACLs in engine as early as possible to avoid security issues
  • Insert instead of append all netbird rules in existing input/output/forward chains
  • Rename existing ACLs to "peer ACLs"
  • Use dedicated type for route ID where possible
  • Use netip.Prefix instead of string where possible

Fix:

  • Management proto and network map:
    • Add default return traffic permit when there's no ACL applied to the network route
    • Fix missing protocol in default rules
    • Partically add IPv6 rules to DNS routes

Remove:

  • Default accept in forward chains
  • Rules in prerouting chains
  • Fwmark accept rules in output chains
  • Src addresses in output chains
  • Dst addresses in input chains
  • Dysfunctional rule in output chains
  • Accept traffic initiated by routed networks behind routing peers in input chains

The prerouting/fwmark parts were used as substitutes for route ACLs to prevent locally routed networks (e.g. containers) from bypassing the input rules (because forward rules match the traffic).

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

🔄 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/2298 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 7/22/2024 **Status:** ✅ Merged **Merged:** 8/6/2024 **Merged by:** [@lixmal](https://github.com/lixmal) **Base:** `feature/network-route-access-control` ← **Head:** `feature/network-route-access-control-client` --- ### 📝 Commits (7) - [`65ea678`](https://github.com/netbirdio/netbird/commit/65ea678ec5b494546d385b3e8a22887aa228db7d) Add route ACLs - [`a9793f0`](https://github.com/netbirdio/netbird/commit/a9793f0325202fc6b4151997b5069fc10e0cbea5) Simplify createContainers - [`54c920d`](https://github.com/netbirdio/netbird/commit/54c920d2b0442ed6c44e125a20f1e83d1a0c1ec5) Fix test - [`0a8bc87`](https://github.com/netbirdio/netbird/commit/0a8bc8735606a5f6a3a1b53eb9f0f28bcf8edd38) Fix mgmt test - [`3040e49`](https://github.com/netbirdio/netbird/commit/3040e490f72da9c3d5390336965e8788e5436f04) Fix cycle - [`138fc56`](https://github.com/netbirdio/netbird/commit/138fc56f7d232673e130d4a6177bcb53aafc6172) Fix lints and remove obsolete code - [`e54a4cd`](https://github.com/netbirdio/netbird/commit/e54a4cdc74134891576a8be3aa2f468890b1d19a) Fix typo ### 📊 Changes **26 files changed** (+1783 additions, -1600 deletions) <details> <summary>View changed files</summary> 📝 `client/firewall/iface.go` (+3 -1) 📝 `client/firewall/iptables/acl_linux.go` (+22 -144) 📝 `client/firewall/iptables/manager_linux.go` (+34 -15) 📝 `client/firewall/iptables/manager_linux_test.go` (+27 -27) 📝 `client/firewall/iptables/router_linux.go` (+183 -207) 📝 `client/firewall/iptables/router_linux_test.go` (+150 -69) 📝 `client/firewall/manager/firewall.go` (+27 -13) 📝 `client/firewall/manager/routerpair.go` (+10 -4) 📝 `client/firewall/nftables/acl_linux.go` (+38 -464) 📝 `client/firewall/nftables/manager_linux.go` (+53 -20) 📝 `client/firewall/nftables/manager_linux_test.go` (+20 -19) ➖ `client/firewall/nftables/route_linux.go` (+0 -431) ➕ `client/firewall/nftables/router_linux.go` (+580 -0) 📝 `client/firewall/nftables/router_linux_test.go` (+309 -80) 📝 `client/firewall/test/cases_linux.go` (+11 -9) 📝 `client/firewall/uspfilter/uspfilter.go` (+34 -11) 📝 `client/firewall/uspfilter/uspfilter_test.go` (+10 -10) ➕ `client/internal/acl/id/id.go` (+26 -0) 📝 `client/internal/acl/manager.go` (+142 -34) 📝 `client/internal/acl/manager_test.go` (+13 -13) _...and 6 more files_ </details> ### 📄 Description ## Describe your changes Add: - Methods to set up forward rules for routed traffic (network ACLs) according to the network map Modify: - Apply ACLs in engine as early as possible to avoid security issues - Insert instead of append all netbird rules in existing input/output/forward chains - Rename existing ACLs to "peer ACLs" - Use dedicated type for route ID where possible - Use `netip.Prefix` instead of `string` where possible Fix: - Management proto and network map: - Add default return traffic permit when there's no ACL applied to the network route - Fix missing protocol in default rules - Partically add IPv6 rules to DNS routes Remove: - Default accept in forward chains - Rules in prerouting chains - Fwmark accept rules in output chains - Src addresses in output chains - Dst addresses in input chains - Dysfunctional rule in output chains - Accept traffic initiated by routed networks behind routing peers in input chains The prerouting/fwmark parts were used as substitutes for route ACLs to prevent locally routed networks (e.g. containers) from bypassing the input rules (because forward rules match the traffic). ## Issue ticket number and link ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [x] It is a refactor - [x] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- <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 04:06:44 -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#16942