Self-Hosted Netbird VPN Setup Guide
A complete guide to setting up a self-hosted Netbird mesh VPN with Authentik SSO integration.
Table of Contents
- Prerequisites
- Server Setup (VPS)
- Authentik SSO Integration
- Homelab Gateway Setup
- Client Setup
- Troubleshooting
Prerequisites
Required Infrastructure
- VPS/Server with public IP address running Linux
- Domain name with DNS configured
- Traefik reverse proxy with Let’s Encrypt SSL
- Authentik SSO server (optional but recommended)
- Docker and Docker Compose installed
Network Requirements
- Ports required on VPS:
80/tcp- HTTP (Traefik)443/tcp- HTTPS (Traefik)3478/udp- STUN- Optional:
51820/udp- WireGuard (if using relay)
Server Setup (VPS)
Step 1: Run Netbird Installation Script
SSH into your VPS and run the official installation script:
curl -fsSL https://github.com/netbirdio/netbird/releases/latest/download/getting-started.sh | bash
Step 2: Configuration Choices
During installation, you’ll be prompted for:
- Domain: Enter your Netbird domain (e.g.,
netbird.example.com) - Reverse proxy: Select
[1] Existing Traefik - External network: Enter your Traefik network name (e.g.,
web) - HTTPS entrypoint: Enter your Traefik HTTPS entrypoint (usually
websecure) - Certificate resolver: Enter your Let’s Encrypt resolver name (e.g.,
letsencrypt)
The script will generate:
/root/docker-compose.yml- Netbird server containers/root/config.yaml- Netbird configuration/root/dashboard.env- Dashboard environment variables
Step 3: Start Netbird Containers
cd /root
docker compose up -d
Verify containers are running:
docker ps | grep netbird
You should see:
netbird-server- Management + Signal + Relaynetbird-dashboard- Web UI
Step 4: Configure Traefik Routes
If using the Traefik Docker provider, the installation script created labels automatically. However, if using an HTTP provider or file-based configuration, you’ll need to add routes manually.
For Traefik file provider, edit your dynamic_config.yml:
http:
routers:
# gRPC routes (highest priority)
netbird-grpc:
rule: "Host(`netbird.example.com`) && (PathPrefix(`/signalexchange.SignalExchange/`) || PathPrefix(`/management.ManagementService/`))"
service: netbird-server-h2c
entryPoints:
- websecure
priority: 20
tls:
certResolver: letsencrypt
# Backend API routes (medium priority)
netbird-backend:
rule: "Host(`netbird.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/oauth2`) || PathPrefix(`/relay`) || PathPrefix(`/ws-proxy/`))"
service: netbird-server
entryPoints:
- websecure
priority: 10
tls:
certResolver: letsencrypt
# Dashboard (lowest priority - catch-all)
netbird-dashboard:
rule: "Host(`netbird.example.com`)"
service: netbird-dashboard
entryPoints:
- websecure
priority: 1
tls:
certResolver: letsencrypt
services:
netbird-dashboard:
loadBalancer:
servers:
- url: "http://netbird-dashboard:80"
netbird-server:
loadBalancer:
servers:
- url: "http://netbird-server:80"
netbird-server-h2c:
loadBalancer:
servers:
- url: "h2c://netbird-server:80"
Restart Traefik:
docker restart traefik
Step 5: Initial Setup
- Navigate to
https://netbird.example.com - You should see the Netbird setup page
- Create the first admin account:
- Name: Your name
- Email: Your email
- Password: Strong password (temporary - we’ll switch to SSO)
- Complete the setup
Important: This creates a local account with embedded Dex authentication. We’ll replace this with Authentik SSO next.
Authentik SSO Integration
Step 1: Create OAuth2 Provider in Authentik
- Log into Authentik (
https://auth.example.com) - Navigate to Applications → Providers → Create
- Select OAuth2/OpenID Provider
- Configure:
- Name:
Netbird - Authentication flow:
default-authentication-flow - Authorization flow:
default-provider-authorization-explicit-consent - Client type:
Confidential - Redirect URIs/Origins (RegEx):
https://netbird.example.com/oauth2/callback https://netbird.example.com/auth https://netbird.example.com/silent-auth - Signing Key:
authentik Self-signed Certificate
- Name:
- Click Create
- Copy the Client ID and Client Secret - you’ll need these
Step 2: Create Application in Authentik
- Navigate to Applications → Applications → Create
- Configure:
- Name:
Netbird - Slug:
netbird - Provider: Select the Netbird provider you just created
- Name:
- Click Create
Step 3: Add Authentik as Identity Provider in Netbird
- Log into Netbird dashboard (
https://netbird.example.com) - Navigate to Settings → Identity Providers
- Click Add Identity Provider
- Select Authentik
- Configure:
- Name:
Authentik - Issuer URL:
https://auth.example.com/application/o/netbird/ - Client ID: Paste from Authentik
- Client Secret: Paste from Authentik
- Redirect/Callback URL: Copy this URL - you may need to add it to Authentik
- Name:
- Click Add Provider
Step 4: Switch to Authentik Authentication
- Log out of Netbird
- Log back in using Authentik
- After successful login, navigate to Settings → Users
- Transfer ownership from the local admin account to your Authentik account
- Delete the local admin account
Netbird now uses Authentik SSO exclusively!
Homelab Gateway Setup
The gateway peer routes traffic from your VPN clients to your homelab network.
Step 1: Generate Setup Key
- In Netbird dashboard, navigate to Setup Keys
- Click Add Setup Key
- Configure:
- Name:
Homelab Gateway - Reusable: Enable (so you can use it multiple times)
- Expires in: 7 days (or longer)
- Ephemeral Peers: Disable (you want permanent registration)
- Name:
- Click Create
- Copy the setup key
Step 2: Install Netbird Client on Homelab Server
For Docker/TrueNAS (recommended):
Create a new stack in Dockge or docker-compose:
services:
netbird-client:
image: netbirdio/netbird:latest
container_name: netbird-client
hostname: homelab-gateway
restart: unless-stopped
network_mode: host
cap_add:
- NET_ADMIN
- SYS_ADMIN
- SYS_RESOURCE
devices:
- /dev/net/tun
environment:
- NB_SETUP_KEY=YOUR_SETUP_KEY_HERE
- NB_MANAGEMENT_URL=https://netbird.example.com
volumes:
- netbird-client:/var/lib/netbird
volumes:
netbird-client:
Replace YOUR_SETUP_KEY_HERE with your actual setup key.
Deploy:
docker compose up -d
For native Linux installation:
curl -fsSL https://pkgs.netbird.io/install.sh | sh
netbird up --setup-key YOUR_SETUP_KEY_HERE --management-url https://netbird.example.com
Step 3: Configure Network Route
- In Netbird dashboard, navigate to Network Routes
- Click Add Route
- Configure:
- Network: Your homelab subnet (e.g.,
192.168.50.0/24) - Description:
Homelab Network - Routing Peer: Select
homelab-gateway - Metric:
9999(low priority) - Distribution Groups: Leave empty (all peers can use it)
- Network: Your homelab subnet (e.g.,
- Click Create
Now any Netbird client can access your entire homelab network through this gateway!
Client Setup
Mobile (Android/iOS)
- Install Netbird from:
- Android: Google Play Store or F-Droid
- iOS: App Store
- Open the app
- Configure:
- Management URL:
https://netbird.example.com
- Management URL:
- Click Login
- Authenticate via Authentik SSO
- Grant VPN permissions when prompted
The app will connect automatically and you can now access your homelab from your phone!
Laptop (Linux)
Installation
Arch Linux:
yay -S netbird
# or
paru -S netbird
Debian/Ubuntu:
curl -fsSL https://pkgs.netbird.io/install.sh | sh
Any Linux:
curl -fsSL https://pkgs.netbird.io/install.sh | sh
Connect with DNS Disabled
To avoid DNS conflicts with your local/work network:
sudo netbird up --disable-dns
This connects to Netbird while preserving your local DNS settings.
Make DNS Disable Permanent
To automatically connect on boot without DNS override:
sudo systemctl edit netbird
Add:
[Service]
ExecStart=
ExecStart=/usr/bin/netbird service run --disable-dns
Save and exit, then:
sudo systemctl daemon-reload
sudo systemctl enable netbird
sudo systemctl start netbird
Verify Connection
netbird status
You should see:
- Management: Connected
- Signal: Connected
- Peers: Shows your gateway and other clients
- Networks:
192.168.50.0/24(or your homelab subnet)
Test homelab access:
ping 192.168.50.1 # Replace with your homelab IP
Laptop (macOS)
- Download Netbird from netbird.io
- Install the
.dmgpackage - Open Netbird from Applications
- Configure:
- Management URL:
https://netbird.example.com
- Management URL:
- Click Login
- Authenticate via Authentik
- Grant VPN permissions
Laptop (Windows)
- Download Netbird from netbird.io
- Run the installer
- Open Netbird from Start Menu
- Configure:
- Management URL:
https://netbird.example.com
- Management URL:
- Click Login
- Authenticate via Authentik
- Grant VPN permissions
Troubleshooting
Server Issues
Dashboard not accessible:
- Check containers are running:
docker ps | grep netbird - Check Traefik routes are configured correctly
- Verify DNS points to your VPS IP
- Check Traefik logs:
docker logs traefik
502 Bad Gateway:
- Ensure
netbird-serverandnetbird-dashboardcontainers are running - Verify they’re on the correct Docker network
- Check Traefik can reach the containers
OAuth errors during Authentik login:
- Verify redirect URIs match exactly in Authentik provider
- Check Client ID and Secret are correct
- Ensure Issuer URL ends with
/(e.g.,https://auth.example.com/application/o/netbird/)
Client Issues
Can’t connect to management server:
- Verify management URL:
https://netbird.example.com - Check firewall allows outbound HTTPS
- Ensure SSL certificate is valid
DNS broken after connecting (Linux):
- Disconnect:
sudo netbird down - Reconnect with DNS disabled:
sudo netbird up --disable-dns - Make it permanent using systemd override (see Linux client setup)
Can’t reach homelab:
- Verify network route exists in Netbird dashboard
- Check gateway peer is connected:
netbird status - Ping gateway peer:
ping 100.86.236.236(use actual gateway Netbird IP) - Verify homelab subnet is correct (e.g.,
192.168.50.0/24)
Connection shows as “Relayed” instead of “P2P”:
- This is normal for peers behind symmetric NAT
- Traffic goes through your VPS relay server
- Still secure and functional, just slightly higher latency
Network Route Not Working
- Check route is enabled in Netbird dashboard
- Verify gateway peer is online
- Ensure gateway peer accepted the network route
- Check routing peer has proper network access
- Verify firewall on gateway allows traffic forwarding
Security Best Practices
- Use Authentik SSO: Centralized authentication with MFA support
- Enable MFA: Configure YubiKey or TOTP in Authentik
- Limit network routes: Only expose necessary subnets
- Use access control: Configure peer groups and policies in Netbird
- Monitor logs: Regularly check Netbird and Authentik logs
- Rotate setup keys: Set expiration dates on setup keys
- Review peer list: Regularly audit connected peers
Advanced Configuration
Multiple Network Routes
You can expose multiple networks:
- Create separate network routes for each subnet
- Assign different routing peers if needed
- Use distribution groups to control which clients can access which networks
Peer Groups and Policies
Control which peers can communicate:
- Create peer groups in Netbird dashboard
- Define access control policies
- Restrict peer-to-peer connections as needed
Custom DNS
Configure Netbird’s DNS for internal name resolution:
- Navigate to DNS in Netbird dashboard
- Add DNS nameservers
- Configure custom domains
High Availability
For production deployments:
- Run multiple Netbird server instances
- Use external PostgreSQL database
- Configure load balancer for management API
- Deploy multiple relay servers
Appendix: Architecture Overview
Network Topology
┌─────────────────┐
│ VPS Server │
│ ┌───────────┐ │
│ │ Netbird │ │
│ │ Server │ │
│ └─────┬─────┘ │
│ │ │
└────────┼────────┘
│
┌────┴────┐
│ │
┌───▼──┐ ┌──▼───┐
│Client│ │Client│
│Peer 1│ │Peer 2│
└──────┘ └──┬───┘
│
┌────▼─────┐
│ Homelab │
│ Gateway │
└────┬─────┘
│
┌──────▼──────┐
│ Homelab │
│ Network │
│192.168.50.x │
└─────────────┘
Component Responsibilities
Netbird Server (VPS):
- Management API - peer registration and configuration
- Signal server - WebRTC signaling for P2P connections
- Relay server - fallback relay for NAT traversal
- STUN server - NAT type detection
Netbird Dashboard:
- Web UI for administration
- User and peer management
- Network route configuration
- Access control policies
Gateway Peer:
- Routes traffic to homelab network
- Runs as Docker container or native service
- Requires network_mode: host for routing
Client Peers:
- Connect to Netbird management server
- Establish P2P or relayed connections
- Route homelab traffic through gateway
- Optional: –disable-dns to preserve local DNS