A comprehensive Python tool for managing NetBird exit nodes and routes with multiple interfaces: command-line, interactive ncurses menu, and system tray applet.
- Exit Node Management: Set, remove, and list exit nodes for any peer
- Route Management: List and analyze NetBird routes
- Multiple Interfaces: CLI, ncurses menu, and system tray applet
- Peer Management: Target specific peers or use current hostname
- Configuration Management: Store API credentials securely
- π₯οΈ Command Line: Full-featured CLI with all options
- π Ncurses Menu: Interactive terminal interface
- π±οΈ System Tray Applet: GUI applet for desktop environments
- Python 3.9+
- NetBird API access with valid credentials
- Poetry for dependency management
- Qt6 (for system tray applet)
- Linux, macOS, or Windows
-
Clone this repository:
git clone <repository-url> cd netbird-exit-node
-
Enter the Nix development shell:
nix develop
-
The tools are now available:
netbird-exit-node --help netbird-exit-node-applet
-
Install Poetry if not available:
pip install poetry
-
Install dependencies:
poetry install
-
Activate virtual environment:
eval "$(poetry env activate)"
Build the package:
nix buildRun the built package:
result/bin/netbird-exit-node --help
result/bin/netbird-exit-node-appletConfigure your NetBird API credentials:
netbird-exit-node config setThis will prompt for:
- API URL: Your NetBird API endpoint (e.g.,
https://api.netbird.io) - Access Token: Your NetBird access token
netbird-exit-node config showYou can also use environment variables (they take precedence over config file):
export NETBIRD_API_URL="https://your-netbird-api.com"
export NETBIRD_ACCESS_TOKEN="your-access-token"Configuration is stored in ~/.config/netbird/netbird-exit-node.json.
List all exit nodes:
netbird-exit-node exit-nodes listSet exit node for current peer:
netbird-exit-node exit-nodes set exit-node-1Set exit node for specific peer:
netbird-exit-node exit-nodes set exit-node-1 --peer hostnameRemove from all exit nodes:
netbird-exit-node exit-nodes rmRemove specific peer from exit nodes:
netbird-exit-node exit-nodes rm --peer hostnameShow exit node information:
netbird-exit-node exit-nodes info
netbird-exit-node exit-nodes info --peer hostnameList routes for current peer:
netbird-exit-node routes listList routes for specific peer:
netbird-exit-node routes list --peer hostnameJSON output:
netbird-exit-node routes list --json-outputSet API credentials:
netbird-exit-node config setShow current configuration:
netbird-exit-node config show--verbose: Enable verbose output for debugging--help: Show help for any command
# Basic exit node management
netbird-exit-node exit-nodes list
netbird-exit-node exit-nodes set exit-node-1
# Managing other peers
netbird-exit-node exit-nodes set exit-node-2 --peer server-1
netbird-exit-node exit-nodes rm --peer mobile-peer
# Route inspection
netbird-exit-node routes list --peer my-server
netbird-exit-node routes list --json-output > routes.json
# Configuration
netbird-exit-node config set
netbird-exit-node config showLaunch the interactive terminal interface:
netbird-exit-nodeMenu Options:
- Set Exit Node: Choose from available exit nodes
- Remove from Exit Nodes: Remove current peer from all exit nodes
- Change Target Peer: Switch to managing a different peer
- Quit: Exit the application
Navigation:
- β/β: Navigate menu options
- Enter: Select option
- Esc/q: Quit application
Features:
- Visual indicators for current exit node status
- Real-time status updates
- Error handling with user-friendly messages
- Peer selection with online status
Launch the GUI system tray applet:
netbird-exit-node-appletFeatures:
- System Tray Icon: Always accessible from taskbar
- Status Display: Shows current exit node in tooltip
- Exit Node Submenu: Direct access to available exit nodes
- Current Node Indicator: π― marks currently active exit node
- Remove Option: Quick removal from exit nodes
- Configuration Dialog: Edit API credentials from GUI
- Auto-refresh: Periodic status updates
Menu Structure:
NetBird Exit Node Manager
βββ Exit Nodes βΊ
β βββ π― exit-node-1 (CURRENT)
β βββ exit-node-2
β βββ exit-node-3
βββ Remove from Exit Nodes
βββ βββββββββββββ
βββ Configuration...
βββ Refresh Status
βββ Quit
Usage:
- Right-click tray icon to open menu
- Hover over "Exit Nodes" to see submenu
- Click exit node name to switch to it
- Click "Remove from Exit Nodes" to disconnect
- Click "Configuration..." to edit API settings
GET /api/peers- List all peers in the networkGET /api/routes- List all routes and exit nodesGET /api/groups- List distribution groupsPOST /api/groups- Create distribution groups for peersPUT /api/groups/{id}- Update group membershipPUT /api/routes/{id}- Update route configurations
Exit Nodes (3 found):
==================================================
π’ Exit Node 1 (ACTIVE):
Name: exit-node-1 β
ID: nb_1234567890abcdef
Total Routes: 1
Enabled Routes: 1 π
Networks: 0.0.0.0/0 (π’ ACTIVE)
π’ Exit Node 2 (ACTIVE):
Name: exit-node-2 β
ID: nb_2345678901bcdefg
Total Routes: 1
Enabled Routes: 1 π
Networks: 0.0.0.0/0 (π’ ACTIVE)
Routes available for peer 'my-computer':
============================================
π Route 1 (ENABLED):
ID: nb_4567890123defghi
Network: 0.0.0.0/0
Description: Default Route via exit-node-1
Exit Node: exit-node-1 (nb_1234567890abcdef)
Groups: peer-my-computer
Metric: 9999
Masquerade: Yes
Domains: None
NetBird Exit Node Information
========================================
Target Peer: my-computer
Required Group Name: peer-my-computer
β
Distribution group 'peer-my-computer' exists
Current Exit Nodes: exit-node-1 (π’ ACTIVE)
Available Groups:
--------------------
β’ All (ID: nb_5678901234efghij, 11 peers)
β’ server (ID: nb_6789012345fghijk, 8 peers)
β’ peer-my-computer (ID: nb_7890123456ghijkl, 1 peers)
Available Exit Nodes:
----------------------
β’ nb_3456789012cdefgh (exit-node-3) (π’ ACTIVE)
β’ nb_2345678901bcdefg (exit-node-2) (π’ ACTIVE)
β’ nb_1234567890abcdef (exit-node-1) (π’ ACTIVE)
The tool provides comprehensive error handling with user-friendly messages:
β Connection Error: Unable to reach the NetBird API server.
Server: https://api.netbird.io
Please check your internet connection and API URL.
β Authentication Error: Invalid access token.
Please check your NetBird access token.
You can get a new token from: https://app.netbird.io/settings/tokens
β Configuration Error: NetBird API credentials not found.
Run 'netbird-exit-node config set' to configure your credentials.
- Input validation for exit node names
- Peer existence verification
- Network connectivity checks
- API response validation
# Enter Nix development shell
nix develop
# Or use Poetry directly
poetry install
poetry shell# Format code
poetry run black .
poetry run isort .
# Lint code
poetry run flake8
# Type checking
poetry run mypy netbird_exit_node/
# Run tests
poetry run pytest# Build with Nix
nix build
# Build wheel with Poetry
poetry buildnetbird_exit_node/
βββ main.py # CLI commands and API client
βββ menu.py # Ncurses interactive interface
βββ applet.py # PyQt6 system tray applet
βββ config.py # Configuration management
βββ __init__.py # Package initialization
- Linux: Full support (CLI, ncurses, applet)
- macOS: Full support (CLI, ncurses, applet)
- Windows: CLI and applet support (ncurses limited)
The system tray applet requires:
- Qt6 libraries
- System tray support in desktop environment
- Proper Qt platform plugins (automatically configured)
If the applet shows platform plugin errors:
# Set Qt platform explicitly
export QT_QPA_PLATFORM=xcb # Linux
export QT_QPA_PLATFORM=cocoa # macOS- Verify API URL and access token
- Check network connectivity
- Ensure access token has proper permissions
- Use
--verboseflag for detailed debugging
# Reset configuration
rm ~/.config/netbird/netbird-exit-node.json
netbird-exit-node config setThis project is licensed under the GNU General Public License v3.0. See LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request