[PR #342] [MERGED] Generate random Peer IP from 100.64.0.0/16 range #12512

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/342
Author: @braginini
Created: 5/29/2022
Status: Merged
Merged: 5/29/2022
Merged by: @braginini

Base: mainHead: random-peer-ip


📝 Commits (9)

  • fe889bf Generate random Peer IP from 100.64.0.0/16 range
  • 3443a2f Fix tests that relied on previous IP allocation logic
  • 457c372 Fix tests that relied on previous IP allocation logic
  • 55eeca9 Remove unused GetNextIP method
  • f3d6cd3 Fix tests that counted on IP Net
  • f1ce0b0 Fix golint error
  • d0e787e Fix Management proto test - support new network
  • a961834 Add random subnet generation
  • d4b2888 Fix code issues and long test run

📊 Changes

9 files changed (+121 additions, -66 deletions)

View changed files

📝 client/testdata/store.json (+1 -1)
📝 go.mod (+1 -0)
📝 go.sum (+2 -0)
📝 management/server/account_test.go (+8 -13)
📝 management/server/management_proto_test.go (+4 -2)
📝 management/server/management_test.go (+4 -6)
📝 management/server/network.go (+61 -43)
management/server/network_test.go (+39 -0)
📝 management/server/testdata/store.json (+1 -1)

📄 Description

The peer IP allocation logic was allocating sequential peer IPs
e.g. 100.64.0.1, 100.64.0.2, etc. from the 100.64.0.0/10 range.
Each account is created with a random subnet from 100.64.0.0/10 range. The total amount of potential subnets is 64. This gives us an option to "physically" groups peers on a subnet level.
The new logic allocates a random peer IP
from the account's subnet.

Example:
Account was created with a subnet 100.75.0.0/16.
New peer was added with an IP 100.75.65.8.


🔄 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/342 **Author:** [@braginini](https://github.com/braginini) **Created:** 5/29/2022 **Status:** ✅ Merged **Merged:** 5/29/2022 **Merged by:** [@braginini](https://github.com/braginini) **Base:** `main` ← **Head:** `random-peer-ip` --- ### 📝 Commits (9) - [`fe889bf`](https://github.com/netbirdio/netbird/commit/fe889bf1e1e245606d097516bd7b743a28aeb1ab) Generate random Peer IP from 100.64.0.0/16 range - [`3443a2f`](https://github.com/netbirdio/netbird/commit/3443a2f661a2c79207aeeb11b5c3af3ce4ad3d17) Fix tests that relied on previous IP allocation logic - [`457c372`](https://github.com/netbirdio/netbird/commit/457c3720cb060ffe819da8588c74a1f975dc3920) Fix tests that relied on previous IP allocation logic - [`55eeca9`](https://github.com/netbirdio/netbird/commit/55eeca9bc5c52d7bc60f26a95019ed1494a096f5) Remove unused GetNextIP method - [`f3d6cd3`](https://github.com/netbirdio/netbird/commit/f3d6cd3b5777bd71b3da516be8a6314ffda329a6) Fix tests that counted on IP Net - [`f1ce0b0`](https://github.com/netbirdio/netbird/commit/f1ce0b044efe694a869cce74b1a51dc819929cab) Fix golint error - [`d0e787e`](https://github.com/netbirdio/netbird/commit/d0e787ec8dae77ae934bcc88b9576eac4f34bb71) Fix Management proto test - support new network - [`a961834`](https://github.com/netbirdio/netbird/commit/a961834e68b57d5d7f44592d7bf3989899d19a19) Add random subnet generation - [`d4b2888`](https://github.com/netbirdio/netbird/commit/d4b2888c04dfaeeadc194097c66ec9c2c6748bb8) Fix code issues and long test run ### 📊 Changes **9 files changed** (+121 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `client/testdata/store.json` (+1 -1) 📝 `go.mod` (+1 -0) 📝 `go.sum` (+2 -0) 📝 `management/server/account_test.go` (+8 -13) 📝 `management/server/management_proto_test.go` (+4 -2) 📝 `management/server/management_test.go` (+4 -6) 📝 `management/server/network.go` (+61 -43) ➕ `management/server/network_test.go` (+39 -0) 📝 `management/server/testdata/store.json` (+1 -1) </details> ### 📄 Description The peer IP allocation logic was allocating sequential peer IPs e.g. 100.64.0.1, 100.64.0.2, etc. from the 100.64.0.0/10 range. Each account is created with a random subnet from 100.64.0.0/10 range. The total amount of potential subnets is 64. This gives us an option to "physically" groups peers on a subnet level. The new logic allocates a random peer IP from the account's subnet. Example: Account was created with a subnet 100.75.0.0/16. New peer was added with an IP 100.75.65.8. --- <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 02:06:04 -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#12512