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
Source and Destination Groups
Source and Destination Groups
Rules specify traffic flow between groups:
- Sources: Groups containing peers that initiate connections
- Destinations: Groups containing peers that receive connections
Protocol Types
Protocol Types
NetBird supports several protocol types:
all: All traffic types (default)tcp: TCP traffic onlyudp: UDP traffic onlyicmp: ICMP/ping trafficnetbird-ssh: NetBird’s built-in SSH access
Port Specifications
Port Specifications
Define allowed ports for TCP/UDP protocols:Examples:
- Single port:
"443","22","3306" - Port range:
"8000-8999","49152-65535" - Multiple specifications:
["80", "443", "8080-8090"]
- Port 443:
{Start: 443, End: 443} - Range 8000-8999:
{Start: 8000, End: 8999}
Traffic Direction
Traffic Direction
Control the direction of allowed traffic:
- Unidirectional (
Bidirectional: false): Traffic flows only from sources to destinations - Bidirectional (
Bidirectional: true): Traffic flows in both directions
When using protocol “all”, the rule is automatically made bidirectional for compatibility.
Traffic Actions
Traffic Actions
Currently, NetBird supports:
accept: Allow matching traffic (default and primary use case)drop: Block matching traffic (reserved for future use)
Creating Policies
Name: "Remote Access to Production"
Description: "Allow remote workers to access production application servers on HTTPS"
Enabled: true
Rule 1: "HTTPS Access"
├── Sources: ["remote-workers"]
├── Destinations: ["prod-app-servers"]
├── Protocol: tcp
├── Ports: ["443"]
└── Bidirectional: false
Rule 2: "SSH Access"
├── Sources: ["remote-workers"]
├── Destinations: ["prod-app-servers"]
├── Protocol: tcp
├── Ports: ["22"]
└── Bidirectional: false
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:- Disable it to enforce zero-trust security
- Modify it to restrict access
- Delete it to start with a clean slate
Policy Validation
NetBird validates policies when creating or updating them:- Group existence: All source and destination groups must exist
- Posture check existence: Referenced posture checks must be valid
- Rule IDs: When updating, rule IDs must match existing rules
- 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:- The policy is enabled (or becomes enabled)
- Referenced groups contain peers or resources
- The policy rules reference network resources
Policy Best Practices
Use Descriptive Names and Documentation
Use Descriptive Names and Documentation
Clearly name policies and rules to reflect their purpose:✅ Good:❌ Bad:
Apply Least Privilege
Apply Least Privilege
Grant only the minimum access necessary:✅ Good:❌ Bad:
Group Related Rules in a Policy
Group Related Rules in a Policy
Use Posture Checks for Sensitive Access
Use Posture Checks for Sensitive Access
Add security requirements to policies protecting critical resources:
Regularly Review and Audit Policies
Regularly Review and Audit Policies
- 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
- Policy is validated (groups, posture checks exist)
- Unique ID is generated
- Policy is stored in the database
- Network serial is incremented
- Activity event is logged
- Affected peers receive updates (if applicable)
Updating a Policy
- Existing policy is retrieved
- New policy is validated
- Changes are compared to determine peer impact
- Policy is saved
- Network serial is incremented
- Activity event is logged
- Affected peers receive updates (if necessary)
Deleting a Policy
- Policy is retrieved
- Peer impact is assessed
- Policy is deleted from database
- Network serial is incremented
- Activity event is logged
- Affected peers receive updates
Rule String Format
NetBird supports a convenient string format for specifying rules: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 createdPolicyUpdated: Policy modifiedPolicyRemoved: Policy deleted
API Reference
Key policy management functions:Related Resources
- Access Control - Overview of NetBird’s security model
- Groups - Organize peers for policies
- Routes - Network routing configuration
- DNS - Private DNS settings