// Why this matters
A netbird zero trust design answers a question traditional VPNs avoid: once someone is connected, what can they reach? With a hub VPN the honest answer is usually "everything in the routed ranges", and the control is a shared secret or a certificate. That is too coarse when operators need to reach a database in one spoke and nothing else.
Peer-to-peer mesh VPNs invert the default. Each device authenticates through the identity provider, and reachability is a policy between named groups. The same model works for laptops, servers and routed subnets, which matters when you are connecting both people and machines to private cloud networks.
The firewall remains essential. The mesh decides who may enter a route; the hub firewall decides what traffic is allowed between spokes and out to the internet. Treating both as code gives you a reviewable history of every access decision.
// The problem
Cloud landing zones push you toward private endpoints and no public IPs. That is right for security and awkward for operations: databases, clusters and internal tools are unreachable from a laptop. The usual workaround is a point-to-site VPN gateway, which is slow to provision, expensive to scale and flat in its trust model.
Firewall rules written in a portal drift. Nobody remembers why a rule exists, rules from departed projects linger, and lower and upper environments diverge in ways that surprise people during incidents.
Finally, access must follow people. When a contractor leaves or an engineer changes team, their reach into private networks should change the same day, driven by the identity system rather than a ticket to the network team.
// The solution
The architecture has three parts. First, a hub virtual network holds the Azure Firewall, a small subnet for routing peers (Linux VMs running the Netbird agent) and private DNS zones linked to the spokes. Second, a Netbird management deployment is connected to the identity provider with SSO and group sync, so mesh groups mirror identity groups. Third, Terraform owns the Azure side (firewall policy, route tables, DNS) and the Netbird side (groups, setup keys, network routes and access policies) through its provider.
A routing peer advertises one or more CIDR ranges to the mesh as a network route. Clients do not get the whole spoke; they get a route that exists only if a policy allows their group to use it. That is the zero-trust part: reachability is a relation between a source group, a destination (route or peer group) and, optionally, ports and protocols, evaluated by the control plane.
Azure Firewall policy is structured as a parent policy with global deny and shared rules, plus a child policy per environment. Rule collections are generated from a map in Terraform variables (name, priority, source, destination, ports), so adding access is a data change with a plan that shows the exact rule created. Spokes use user-defined routes sending 0.0.0.0/0 and inter-spoke traffic through the firewall, which is what makes the rules binding.
We rejected a gateway-based point-to-site VPN (flat trust and slow scaling), per-spoke bastions for everything (good for SSH, poor for databases and web tools) and opening private endpoints to the internet behind allowlists (brittle and widens exposure). Related designs: the Bastion tunnel approach in Platform Operator Tooling: Terraform Plan to Markdown and Private AKS Access via Bastion is a good complement for Kubernetes API access, and One Config, Two Clouds: Group and Role Management as Code explains how the groups that drive policy are produced.
- Hub networkfirewall, routing peer subnet, private DNS
- Mesh control planemanagement service, identity provider integration
- Routing peeradvertises selected private ranges into the mesh
- Groupsidentity groups mapped to mesh groups
- Gate: access policy gatesource group, destination route, ports
- Firewall policyrule collections as code per environment
- Operator connectsclient enrols with SSO
- Private DNSnames resolve only inside the mesh
- Auditpeer and firewall logs to central workspace
// Before you start
- An Azure hub subscription with permission to create virtual networks, firewalls and route tables.
- A Netbird management service (self-hosted or cloud) with an identity provider integration (Entra ID or similar).
- Terraform 1.5+ with the
azurermandnetbirdproviders and an API token for Netbird stored in your secret manager. - Linux VM image with outbound access to the management service and WireGuard UDP allowed.
- A CIDR plan for hub, spokes and any ranges you will advertise (no overlaps).
- Familiarity with Azure Firewall policy hierarchy and user-defined routes.
// Step-by-step implementation
01 Plan the address space and build the hub with the firewall
Write down the CIDRs first. The mesh itself uses an overlay range (a /16 from a private block is typical) that must not overlap anything on-premises or in the cloud. Then build the hub network with an AzureFirewallSubnet, a subnet for routing peers and a management subnet.
A Standard or Premium firewall with a policy attached is the anchor; everything later adds rules to that policy.
02 Generate firewall rule collections from data
Express access as a map and loop over it. Each entry is one explicit allow; the parent policy already carries the global deny. A priority range per kind of rule keeps the ordering understandable.
Because the policy is data, a review shows exactly which source, destination and port a change opens.
03 Force spoke traffic through the firewall
A rule in the firewall does nothing if packets never reach it. Attach a route table to each spoke subnet with a default route to the firewall's private address and propagate nothing else. For the routing peer subnet, send spoke-bound traffic to the firewall as well.
Peer the hub with every spoke and allow forwarded traffic on the hub side.
04 Deploy routing peers and join them to the mesh
A routing peer is a small Linux VM with IP forwarding enabled and the Netbird agent enrolled with a setup key. Use a reusable key limited to a group, with an expiry, and keep it in your secret store. Two peers in separate zones give you redundancy; Netbird can load-balance or fail over between peers advertising the same route.
Enable IP forwarding on the NIC in Azure as well as inside the OS; forgetting one is the classic reason a routed range does not work.
05 Define groups, routes and policies with the Netbird provider
Now the zero-trust part, as code. Create a group for the routing peers, a group per identity team, a network route advertising the destination range through the routing peers, and a policy allowing exactly the group and ports you intend.
Policies are unidirectional by default in the sense that the source initiates; start with the narrowest ports and widen with evidence.
06 Make private names resolve inside the mesh
Reaching a private endpoint by IP is a poor operator experience. Link the private DNS zones to the hub network, add a DNS forwarder (the firewall DNS proxy works) and publish a nameserver group in the mesh for the private zone suffix. Clients then resolve internal names only while connected.
Use a match domain so only the private suffix goes to the internal resolver; everything else keeps using the client's normal DNS.
// How to verify it works
netbird status -don a client lists the routing peers as connected and shows the advertised route as selected.- From a client in
db-admins,nc -vz <db-private-name> 5432succeeds; from a client outside the group it fails because the route is not distributed. - Azure Firewall logs show the allowed flow hitting the
mesh-to-dbrule and no hits on a rule you did not intend. nslookup <service>.<private-zone>resolves to a private address only while connected to the mesh.- Removing a user from the identity group removes the route from their client within the sync interval.
// Design decisions and trade-offs
- Peer-to-peer WireGuard mesh with identity-based access policies instead of a classic hub VPN that puts everyone on one flat network.
- Routing peers in the hub advertise only specific private ranges, and policies decide who can reach which route.
- Identity provider groups map to mesh groups, so access follows team membership.
- Azure Firewall rule collections are generated from data, with lower and upper environments using separate policies.
- Default deny everywhere; each access path is an explicit, reviewed rule.
// Pitfalls and lessons learned
- Overlapping CIDRs between the mesh overlay, spokes and a user's home network cause baffling routing; allocate and document ranges before building anything.
- IP forwarding must be enabled in both the Azure NIC and the OS. Either alone yields a tunnel that connects and carries nothing.
- The firewall sees traffic from the routing peer's address (with masquerade), not the user's. Write rules against the peer subnet and use the mesh policy for user-level control.
- Asymmetric routing happens when return traffic bypasses the firewall; keep the UDRs symmetric on every spoke.
- Setup keys that never expire are credentials. Use expiring, group-scoped keys and rotate them like any secret.
- If group sync lags, a new hire can sit without access for a while; know the sync interval and tell people.
- A single routing peer is a single point of failure for the route; run two and test failover by stopping one.
// Frequently asked questions
What is the difference between Netbird and a traditional VPN?
Netbird builds peer-to-peer WireGuard connections and applies access policies between groups, so reaching the network does not imply reaching everything on it.
Can Terraform manage Netbird?
Yes, there is a Netbird Terraform provider covering groups, routes, policies, setup keys and nameserver groups.
Do I still need Azure Firewall with a mesh VPN?
Yes. The mesh controls who can enter a route; the firewall controls east-west and outbound traffic between networks and gives central logging.
How many routing peers should I run?
At least two per advertised route, in different zones, so one failure does not remove access.
How do I give a contractor temporary access?
Put them in a dedicated identity group with a time-boxed membership; the mesh policy follows the group.
// The outcome
Operators reach private resources through a mesh that checks who they are and what they may reach, and the hub firewall carries only explicit, versioned rules. Joining or leaving a team changes access automatically instead of through ticketed firewall edits.
// Where to take it next
- Ship mesh and firewall logs to a central workspace and alert on policy changes; see Watching the Watchers: Identity-Tampering Detection with ChatOps Triage.
- Use Typos Cannot Reach Production: Declarative SaaS Access with Plan-Time Guards style review gates for changes to access policies.
- Add per-service posture checks (OS version, device approval) as mesh policy conditions.
- Combine with the Bastion approach in Platform Operator Tooling: Terraform Plan to Markdown and Private AKS Access via Bastion for Kubernetes API access.