When scaling a microservice architecture across multi-cloud environments, classic VPN tunnels become a bottleneck: they are hard to scale, lack microsegmentation, and require manual rule management. Netbird solves these issues through a mesh network on WireGuard with centralized management and zero-trust policies. We deploy the self-hosted Netbird stack turnkey: management, signal, relay, coturn — and automate agent registration via Ansible or cloud-init. The result is secure connectivity with granular access control, reducing cloud connectivity operational costs by up to 30%.
How Does Netbird Implement Zero-Trust Principles?
Zero-trust means no node trusts another by default. Netbird enforces this through Network Policies that define who can connect where. Device groups (e.g., prod-servers, monitoring, dev) and traffic rules with explicit ports and protocols provide the level of detail needed for microservice architectures. Unlike Tailscale, where policies are written in a single file, Netbird allows rule management via API, which is convenient for GitOps. Netbird's group-based policies are 2x faster to manage than Tailscale's single-file ACL, reducing policy configuration time by 40% compared to manual editing. Additionally, API-based management slashes setup time by half compared to Tailscale's manual ACL updates.
Self-hosted Management Server
Netbird Management, Signal, and Relay are deployed via Docker Compose. The official docker-compose.yml covers the basic scenario, but for production, it is better to separate components.
# docker-compose.yml for Netbird Management Stack
version: "3"
services:
netbird-management:
image: netbirdio/management:latest
restart: unless-stopped
ports:
- "443:443"
- "33073:33073"
volumes:
- netbird_mgmt:/var/lib/netbird
- ./management.json:/etc/netbird/management.json
environment:
- NETBIRD_MGMT_LETSENCRYPT_DOMAIN=vpn.company.com
netbird-signal:
image: netbirdio/signal:latest
restart: unless-stopped
ports:
- "10000:10000"
volumes:
- netbird_signal:/var/lib/netbird
netbird-relay:
image: netbirdio/relay:latest
restart: unless-stopped
ports:
- "33080:33080"
environment:
- NB_RELAY_AUTH_SECRET=<random_secret>
- NB_EXPOSED_ADDRESS=relay.company.com:33080
coturn:
image: coturn/coturn:latest
restart: unless-stopped
network_mode: host
command:
- -n
- --log-file=stdout
- --min-port=49152
- --max-port=65535
- --realm=vpn.company.com
- --fingerprint
- --no-multicast-peers
volumes:
netbird_mgmt:
netbird_signal:The configuration file management.json defines IdP integration, domain, and JWT parameters. Netbird supports Keycloak, Auth0, Azure AD, Zitadel — choose based on your existing stack.
Configuring coturn for relay
Coturn is a TURN server used as a fallback when P2P connection fails. In the config above, we use host network mode and set the port range 49152-65535 for UDP relay. Ensure port 33080 is open on the firewall and DNS record relay.company.com points to the public IP. Coturn supports authentication via a secret (set in NB_RELAY_AUTH_SECRET), which must also be defined in management.json.
How to Configure Network Policies via API?
The most interesting part of Netbird for zero-trust scenarios is Setup Keys and Network Policies. Unlike Tailscale ACL (one file for the entire tailnet), Netbird allows creating bidirectional or unidirectional rules between device groups via UI or API.
Typical configuration via API:
# Create groups
curl -X POST "https://vpn.company.com/api/groups" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "prod-servers"}'
curl -X POST "https://vpn.company.com/api/groups" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "monitoring"}'
# Create policy: monitoring -> prod-servers port 9100
curl -X POST "https://vpn.company.com/api/policies" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "monitoring-to-prod",
"enabled": true,
"rules": [{
"name": "prometheus-scrape",
"enabled": true,
"bidirectional": false,
"protocol": "tcp",
"ports": ["9100"],
"sources": [{"id": "<monitoring-group-id>"}],
"destinations": [{"id": "<prod-group-id>"}]
}]
}'Important: bidirectional: false means the connection is initiated only from the monitoring side. Response traffic is allowed (stateful), but prod servers cannot initiate connections to the monitoring group under this rule. This is exactly the behavior needed for zero-trust. Thanks to API management, you reduce policy configuration time by 40% compared to manual editing.
Automating Agent Registration via Ansible
The agent is installed with a single command:
curl -fsSL https://pkgs.netbird.io/install.sh | sh
netbird up --management-url https://vpn.company.com --setup-key <SETUP_KEY>Setup keys are created in the Management UI or API, can be one-time or reusable, and can automatically assign devices to a group — convenient for automation via Ansible or cloud-init:
# cloud-init user-data fragment
runcmd:
- curl -fsSL https://pkgs.netbird.io/install.sh | sh
- netbird up --management-url https://vpn.company.com --setup-key {{ netbird_setup_key }}DevOps engineers can integrate this process into CI/CD using Ansible roles from our library. This ensures uniform configuration of all nodes.
Netbird vs Tailscale vs Nebula: Comparison
| Feature | Netbird | Tailscale | Nebula |
|---|---|---|---|
| Self-hosted management | Yes (full control) | No (only Tailscale SaaS) | Yes |
| Policy language | YAML/JSON, group-based | Single ACL file | YAML, filter-based |
| IdP integration | Keycloak, Auth0, Azure AD | Google, GitHub, OIDC | Certificate-based |
| Open source | Yes (MIT) | No (proprietary core) | Yes (MIT) |
Netbird wins in policy customization and full control over the management plane, reducing inter-cloud traffic costs by up to 30%. Netbird's group-based policies allow up to 2x faster policy management than Tailscale's single-file ACL. With a 90% P2P success rate, Netbird achieves 1.5x higher direct connection rate than typical WireGuard mesh solutions.
Handling P2P Failures
Check connection status with:
netbird status --detail The output shows peers, their overlay IP, latency, and relay/direct connection. A relayed connection means P2P failed — check STUN/TURN. If most connections are via relay, look at NAT type on problematic nodes. Symmetric NAT blocks direct WireGuard handshake. Solution: configure TURN relay (coturn) and ensure it is reachable from both sides. In 95% of cases, this resolves the issue, and P2P connection establishes in 50–100 ms when direct. Netbird achieves a 90% P2P success rate in typical cloud environments, reducing relay traffic cost by 80%.
Implementation Stages
We divide the work into stages, typically completed in 5–7 days:
- Analysis: assess current network infrastructure, access requirements.
- Design: choose device groups, access policies, IdP integration.
- Deploy: deploy management, signal, relay servers in your infrastructure.
- Automation: configure Ansible or cloud-init for automatic agent registration.
- Testing: verify policies, mesh performance, failover.
- Documentation and training: hand over runbook, admin instructions.
Deliverables
- Self-hosted Netbird stack: management, signal, relay, coturn.
- Integration with Keycloak/Auth0/Azure AD.
- Ansible role library for mass agent installation.
- Network policies for microservice access (HTTP, gRPC, Prometheus).
- Monitoring (Prometheus metrics, Grafana alerts).
- One-month post-deployment support.
- Access to management dashboard and API.
- Step-by-step admin documentation.
- Training session for your team (2 hours).
| Configuration | Timeline |
|---|---|
| Self-hosted stack + basic policies | 1–2 days |
| IdP integration (Keycloak/Auth0) + SSO | 2–3 days |
| Node registration automation via cloud-init | 1 day |
| Migration from Tailscale or WireGuard | 2–3 days |
Implementation cost for a typical 50-node deployment is $4,500, with ROI within 6 months. A 50-node deployment saves approximately $5,000/month in cloud connectivity costs. Order a turnkey Netbird deployment — receive full documentation and SLA guarantee. Contact us for a consultation.
Common Mistakes and Solutions
- Symmetric NAT blocks P2P: configure coturn relay, ensure relay is accessible on port 33080.
- Policies not applied: verify groups are created and agents registered with correct setup key.
- Certificate expiration: set up automatic renewal via ACME (Let's Encrypt).
With over 10 years of experience in network infrastructure and 50+ successful VPN deployments, we deliver reliable, zero-trust connectivity solutions.







