[PR #2408] [MERGED] Add permissive legacy routing rules if the management server is outdated #15096

Closed
opened 2026-08-05 03:06:58 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/2408
Author: @lixmal
Created: 8/8/2024
Status: Merged
Merged: 8/14/2024
Merged by: @lixmal

Base: feature/network-route-access-controlHead: route-acl-default-allow-on-old-mgmt


📝 Commits (10+)

  • 9b8bd08 Remove outbound rules
  • 7c2423f Add permissive legacy routing rules if the management server is outdated
  • c5bcabf Add established rules to in/output chains to allow route client return traffic.
  • c2bcf4b Adjust nftables test to account for the new established rule
  • 7c8ef0d Remove obsolete iif/oif in inner input/output chain rules
  • e9f53a6 Remove outbound rules from test
  • bc62507 Add back the inverse NAT rule for site2site traffic with route ACLs
  • 50c4bec Reinsert mistakenly removed policy check
  • e840a6c Fix route rule and nat rule removal
  • 790b970 Remove dst ip subnet in iptables output chain to align with nftables

📊 Changes

16 files changed (+498 additions, -254 deletions)

View changed files

📝 client/firewall/iptables/acl_linux.go (+14 -4)
📝 client/firewall/iptables/manager_linux.go (+8 -0)
📝 client/firewall/iptables/router_linux.go (+113 -60)
📝 client/firewall/iptables/router_linux_test.go (+10 -10)
📝 client/firewall/manager/firewall.go (+37 -5)
📝 client/firewall/manager/routerpair.go (+2 -0)
📝 client/firewall/nftables/acl_linux.go (+12 -37)
📝 client/firewall/nftables/manager_linux.go (+54 -4)
📝 client/firewall/nftables/manager_linux_test.go (+28 -9)
📝 client/firewall/nftables/router_linux.go (+174 -96)
📝 client/firewall/nftables/router_linux_test.go (+29 -8)
📝 client/firewall/uspfilter/uspfilter.go (+5 -0)
📝 client/internal/acl/manager.go (+10 -5)
📝 management/server/peer_test.go (+0 -1)
📝 management/server/route.go (+1 -5)
📝 management/server/route_test.go (+1 -10)

📄 Description

Describe your changes

  • Add legacy routing rules if the mgmt server is outdated and clear them up if the client reconnects to the updated mgmt server. This restores pre-route-ACL behavior

  • Replace permissive outbound forward rules with established ones. This allows us to respect a configured policy drop on the forward chain while maintaining permitting return traffic for the permissive inbound rule.
    The route ACLs on routing peers enforce the inbound rule and are empty on pure routing clients (which results in a drop).

  • Add an established rule to INPUT (and OUTPUT for consistency) to allow return traffic of routing client outbound traffic towards network routes on routing peers

  • Remove obsolete iif/oof interface in inner input/output rules

  • Remove NAT early exit on lo and instead restrict with iif/oif

Example nftables output

table ip filter {
        chain FORWARD {
                type filter hook forward priority filter; policy accept;
                oifname "wt0" ct state established,related counter packets 0 bytes 0 accept
                iifname "wt0" counter packets 0 bytes 0 accept
        }
}
table ip netbird {
        chain netbird-rt-fwd {
                ct state established,related accept
                ip saddr 100.64.209.41 ip daddr 20.0.0.0/24 meta l4proto icmp counter packets 1 bytes 84 accept
        }

        chain netbird-rt-nat {
                type nat hook postrouting priority srcnat - 1; policy accept;
                iifname "wt0" ip daddr 20.0.0.0/24 counter packets 1 bytes 84 masquerade
                oifname "wt0" ip saddr 20.0.0.0/24 counter packets 2 bytes 168 masquerade
        }

        chain netbird-acl-input-rules {
                ct state established,related accept
                iifname "wt0" tcp dport 80 accept
        }

        chain netbird-acl-output-rules {
                ct state established,related accept
                oifname "wt0" tcp sport 80 accept
        }

        chain netbird-acl-input-filter {
                type filter hook input priority filter; policy accept;
                iifname "wt0" jump netbird-acl-input-rules
                iifname "wt0" drop
        }

        chain netbird-acl-output-filter {
                type filter hook output priority filter; policy accept;
                oifname "wt0" ip daddr != 100.64.0.0/16 accept
                oifname "wt0" jump netbird-acl-output-rules
                oifname "wt0" drop
        }

        chain netbird-acl-forward-filter {
                type filter hook forward priority filter; policy accept;
                iifname "wt0" jump netbird-rt-fwd
                iifname "wt0" drop
        }
}

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/2408 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 8/8/2024 **Status:** ✅ Merged **Merged:** 8/14/2024 **Merged by:** [@lixmal](https://github.com/lixmal) **Base:** `feature/network-route-access-control` ← **Head:** `route-acl-default-allow-on-old-mgmt` --- ### 📝 Commits (10+) - [`9b8bd08`](https://github.com/netbirdio/netbird/commit/9b8bd08d3e9310d1ec2db3b42ab19e8c5b0e128c) Remove outbound rules - [`7c2423f`](https://github.com/netbirdio/netbird/commit/7c2423fef55ce16a8f46c8a9b3ada19f7dee9643) Add permissive legacy routing rules if the management server is outdated - [`c5bcabf`](https://github.com/netbirdio/netbird/commit/c5bcabf73708878115a4366bf3f766f42050a53a) Add established rules to in/output chains to allow route client return traffic. - [`c2bcf4b`](https://github.com/netbirdio/netbird/commit/c2bcf4b88b1403a59a2fb70f417f33724dd592df) Adjust nftables test to account for the new established rule - [`7c8ef0d`](https://github.com/netbirdio/netbird/commit/7c8ef0d5aec9e40edcacec4e3af4b0602be80b99) Remove obsolete iif/oif in inner input/output chain rules - [`e9f53a6`](https://github.com/netbirdio/netbird/commit/e9f53a602f1af15df4442f89015e694dfe24d256) Remove outbound rules from test - [`bc62507`](https://github.com/netbirdio/netbird/commit/bc62507182905045cb82e3136265f546fb64075b) Add back the inverse NAT rule for site2site traffic with route ACLs - [`50c4bec`](https://github.com/netbirdio/netbird/commit/50c4bec89b8ebd5d8a114f7826de60106c45b998) Reinsert mistakenly removed policy check - [`e840a6c`](https://github.com/netbirdio/netbird/commit/e840a6ce9a1f6e1044382885b3be1e8ba7a35c4f) Fix route rule and nat rule removal - [`790b970`](https://github.com/netbirdio/netbird/commit/790b9700e723688b57f11d858c963b7285a930d3) Remove dst ip subnet in iptables output chain to align with nftables ### 📊 Changes **16 files changed** (+498 additions, -254 deletions) <details> <summary>View changed files</summary> 📝 `client/firewall/iptables/acl_linux.go` (+14 -4) 📝 `client/firewall/iptables/manager_linux.go` (+8 -0) 📝 `client/firewall/iptables/router_linux.go` (+113 -60) 📝 `client/firewall/iptables/router_linux_test.go` (+10 -10) 📝 `client/firewall/manager/firewall.go` (+37 -5) 📝 `client/firewall/manager/routerpair.go` (+2 -0) 📝 `client/firewall/nftables/acl_linux.go` (+12 -37) 📝 `client/firewall/nftables/manager_linux.go` (+54 -4) 📝 `client/firewall/nftables/manager_linux_test.go` (+28 -9) 📝 `client/firewall/nftables/router_linux.go` (+174 -96) 📝 `client/firewall/nftables/router_linux_test.go` (+29 -8) 📝 `client/firewall/uspfilter/uspfilter.go` (+5 -0) 📝 `client/internal/acl/manager.go` (+10 -5) 📝 `management/server/peer_test.go` (+0 -1) 📝 `management/server/route.go` (+1 -5) 📝 `management/server/route_test.go` (+1 -10) </details> ### 📄 Description ## Describe your changes - Add legacy routing rules if the mgmt server is outdated and clear them up if the client reconnects to the updated mgmt server. This restores pre-route-ACL behavior - Replace permissive outbound forward rules with `established` ones. This allows us to respect a configured policy `drop` on the forward chain while maintaining permitting return traffic for the permissive inbound rule. The route ACLs on routing peers enforce the inbound rule and are empty on pure routing clients (which results in a drop). - Add an `established` rule to `INPUT` (and `OUTPUT` for consistency) to allow return traffic of routing client outbound traffic towards network routes on routing peers - Remove obsolete iif/oof interface in inner input/output rules - Remove NAT early exit on `lo` and instead restrict with iif/oif Example nftables output ``` table ip filter { chain FORWARD { type filter hook forward priority filter; policy accept; oifname "wt0" ct state established,related counter packets 0 bytes 0 accept iifname "wt0" counter packets 0 bytes 0 accept } } table ip netbird { chain netbird-rt-fwd { ct state established,related accept ip saddr 100.64.209.41 ip daddr 20.0.0.0/24 meta l4proto icmp counter packets 1 bytes 84 accept } chain netbird-rt-nat { type nat hook postrouting priority srcnat - 1; policy accept; iifname "wt0" ip daddr 20.0.0.0/24 counter packets 1 bytes 84 masquerade oifname "wt0" ip saddr 20.0.0.0/24 counter packets 2 bytes 168 masquerade } chain netbird-acl-input-rules { ct state established,related accept iifname "wt0" tcp dport 80 accept } chain netbird-acl-output-rules { ct state established,related accept oifname "wt0" tcp sport 80 accept } chain netbird-acl-input-filter { type filter hook input priority filter; policy accept; iifname "wt0" jump netbird-acl-input-rules iifname "wt0" drop } chain netbird-acl-output-filter { type filter hook output priority filter; policy accept; oifname "wt0" ip daddr != 100.64.0.0/16 accept oifname "wt0" jump netbird-acl-output-rules oifname "wt0" drop } chain netbird-acl-forward-filter { type filter hook forward priority filter; policy accept; iifname "wt0" jump netbird-rt-fwd iifname "wt0" drop } } ``` ## Issue ticket number and link ### Checklist - [x] 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 --- <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 03:06:58 -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#15096