[PR #4866] feat(client): auto-reconfigure WireGuard interface on peer IP change #26479

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/4866
Author: @fahrishih
Created: 11/27/2025
Status: 🔄 Open

Base: mainHead: feat/client-auto-reconfigure-ip


📝 Commits (2)

  • cdafea7 feat(client): auto-reconfigure WireGuard interface on peer IP change
  • a13fab9 fix: restart SSH server on WireGuard IP address change

📊 Changes

5 files changed (+477 additions, -4 deletions)

View changed files

📝 client/internal/engine.go (+84 -4)
📝 client/internal/engine_ssh.go (+1 -0)
📝 client/internal/engine_test.go (+300 -0)
📝 client/ssh/server/server.go (+12 -0)
📝 client/ssh/server/server_test.go (+80 -0)

📄 Description

Added

  • Automatic WireGuard interface reconfiguration when peer IP changes
  • The NetBird client now detects changes to the self peer’s IP address delivered by the Management Service and applies them live without requiring netbird down / netbird up. This is a more scalable approach for someone who has many peers and impossible to restart 1 by 1.

Improved

  • Enhanced client engine logic to watch for self-IP updates from network map diffs.
  • Added logic to update interface address, routes, and internal state when the IP changes.
  • Reduced downtime during CIDR migrations and tenant-level IP reassignment.
  • Improved consistency between Management-assigned IPs and the active local WireGuard configuration.

Fixed

  • Fixed issue where the client received new IP configuration from Management but did not reconfigure the local interface until a manual reconnect.
  • Fixed mismatch between API IP and active wtX/utunX interface, resulting in routing inconsistencies.

Notes

  • Implementation tested on macOS and Linux client builds.
  • WG interface name handling remains platform-specific:
  • macOS uses utun*
  • Linux uses wg0 / kernel interface path

This enhancement significantly improves NetBird’s dynamic IP behavior and avoids downtime during network CIDR changes.

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)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Summary by CodeRabbit

  • New Features

    • Hot-update of the local WireGuard IP during config changes.
    • Automatic SSH rebind and firewall DNAT refresh when the node IP changes.
    • Local IP state is refreshed to reflect address changes.
  • Bug Fixes

    • Config updates now continue if an IP update fails; failures are logged rather than aborting.
  • Tests

    • Added tests for IP-update scenarios, SSH restart lifecycle, and firewall/DNAT interactions.

✏️ Tip: You can customize this high-level summary in your review settings.


🔄 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/4866 **Author:** [@fahrishih](https://github.com/fahrishih) **Created:** 11/27/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/client-auto-reconfigure-ip` --- ### 📝 Commits (2) - [`cdafea7`](https://github.com/netbirdio/netbird/commit/cdafea70503781f63f9814b23b0e88cf89e593d3) feat(client): auto-reconfigure WireGuard interface on peer IP change - [`a13fab9`](https://github.com/netbirdio/netbird/commit/a13fab9103319d256f63d4c6b95244e5cb7be13e) fix: restart SSH server on WireGuard IP address change ### 📊 Changes **5 files changed** (+477 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `client/internal/engine.go` (+84 -4) 📝 `client/internal/engine_ssh.go` (+1 -0) 📝 `client/internal/engine_test.go` (+300 -0) 📝 `client/ssh/server/server.go` (+12 -0) 📝 `client/ssh/server/server_test.go` (+80 -0) </details> ### 📄 Description ### Added - Automatic WireGuard interface reconfiguration when peer IP changes - The NetBird client now detects changes to the self peer’s IP address delivered by the Management Service and applies them live without requiring netbird down / netbird up. This is a more scalable approach for someone who has many peers and impossible to restart 1 by 1. ### Improved - Enhanced client engine logic to watch for self-IP updates from network map diffs. - Added logic to update interface address, routes, and internal state when the IP changes. - Reduced downtime during CIDR migrations and tenant-level IP reassignment. - Improved consistency between Management-assigned IPs and the active local WireGuard configuration. ### Fixed - Fixed issue where the client received new IP configuration from Management but did not reconfigure the local interface until a manual reconnect. - Fixed mismatch between API IP and active wtX/utunX interface, resulting in routing inconsistencies. ### Notes - Implementation tested on macOS and Linux client builds. - WG interface name handling remains platform-specific: - macOS uses utun* - Linux uses wg0 / kernel interface path **This enhancement significantly improves NetBird’s dynamic IP behavior and avoids downtime during network CIDR changes.** ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Hot-update of the local WireGuard IP during config changes. * Automatic SSH rebind and firewall DNAT refresh when the node IP changes. * Local IP state is refreshed to reflect address changes. * **Bug Fixes** * Config updates now continue if an IP update fails; failures are logged rather than aborting. * **Tests** * Added tests for IP-update scenarios, SSH restart lifecycle, and firewall/DNAT interactions. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- 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 07:07: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#26479