Skip to main content

Policies

Policies define the access control rules that determine which peers can communicate with each other in your NetBird network. Each policy contains one or more rules that specify allowed connections between groups.

Policy Structure

A NetBird policy consists of:

Policy Components

  • Name and Description: Identify the policy and explain its purpose
  • Enabled Status: Control whether the policy is active without deleting it
  • Rules: One or more rules defining allowed traffic patterns
  • Source Posture Checks: Optional security requirements for source peers

Policy Rules

Each rule within a policy defines specific access permissions:

Rule Components

Rules specify traffic flow between groups:
  • Sources: Groups containing peers that initiate connections
  • Destinations: Groups containing peers that receive connections
Example:
NetBird supports several protocol types:
  • all: All traffic types (default)
  • tcp: TCP traffic only
  • udp: UDP traffic only
  • icmp: ICMP/ping traffic
  • netbird-ssh: NetBird’s built-in SSH access
From the source code:
Define allowed ports for TCP/UDP protocols:
  • Single port: "443", "22", "3306"
  • Port range: "8000-8999", "49152-65535"
  • Multiple specifications: ["80", "443", "8080-8090"]
Ports are stored as ranges internally:
Examples:
  • Port 443: {Start: 443, End: 443}
  • Range 8000-8999: {Start: 8000, End: 8999}
Control the direction of allowed traffic:
  • Unidirectional (Bidirectional: false): Traffic flows only from sources to destinations
  • Bidirectional (Bidirectional: true): Traffic flows in both directions
Example:
When using protocol “all”, the rule is automatically made bidirectional for compatibility.
Currently, NetBird supports:
  • accept: Allow matching traffic (default and primary use case)
  • drop: Block matching traffic (reserved for future use)

Creating Policies

Policy Examples

Allow Full Internal Communication

Restricted Database Access

Multi-Protocol Web Access

SSH with Posture Checks

Default Policy

When you create a NetBird account, a default policy is automatically created:
This policy allows all peers to communicate freely. You can:
  • Disable it to enforce zero-trust security
  • Modify it to restrict access
  • Delete it to start with a clean slate
Disabling or deleting the default policy will immediately block all peer-to-peer communication. Ensure you have appropriate policies in place before removing the default policy.

Policy Validation

NetBird validates policies when creating or updating them:
Validation checks:
  1. Group existence: All source and destination groups must exist
  2. Posture check existence: Referenced posture checks must be valid
  3. Rule IDs: When updating, rule IDs must match existing rules
  4. Auto-generated IDs: New policies get automatic unique IDs

Policy Updates and Network Impact

When you modify a policy, NetBird intelligently determines if peer configurations need updating:
Peer updates are triggered only when:
  • The policy is enabled (or becomes enabled)
  • Referenced groups contain peers or resources
  • The policy rules reference network resources
This optimization minimizes unnecessary network updates and peer configuration changes.

Policy Best Practices

Clearly name policies and rules to reflect their purpose:✅ Good:
❌ Bad:
Grant only the minimum access necessary:✅ Good:
❌ Bad:
Add security requirements to policies protecting critical resources:
  • Review policies quarterly to ensure they still reflect business needs
  • Remove or disable unused policies
  • Check activity logs for denied access attempts
  • Validate that groups still contain appropriate peers

Policy Lifecycle

Creating a Policy

  1. Policy is validated (groups, posture checks exist)
  2. Unique ID is generated
  3. Policy is stored in the database
  4. Network serial is incremented
  5. Activity event is logged
  6. Affected peers receive updates (if applicable)

Updating a Policy

  1. Existing policy is retrieved
  2. New policy is validated
  3. Changes are compared to determine peer impact
  4. Policy is saved
  5. Network serial is incremented
  6. Activity event is logged
  7. Affected peers receive updates (if necessary)

Deleting a Policy

  1. Policy is retrieved
  2. Peer impact is assessed
  3. Policy is deleted from database
  4. Network serial is incremented
  5. Activity event is logged
  6. Affected peers receive updates

Rule String Format

NetBird supports a convenient string format for specifying rules:
Format: protocol/port or protocol/port-range Examples:
  • "tcp/443" → TCP port 443
  • "udp/53" → UDP port 53
  • "tcp/8000-8999" → TCP ports 8000-8999
  • "all" → All protocols
  • "icmp" → ICMP only

Activity Logging

All policy operations are logged:
  • PolicyAdded: New policy created
  • PolicyUpdated: Policy modified
  • PolicyRemoved: Policy deleted
Event metadata includes:

API Reference

Key policy management functions:
  • Access Control - Overview of NetBird’s security model
  • Groups - Organize peers for policies
  • Routes - Network routing configuration
  • DNS - Private DNS settings