Client Environment Variables

The NetBird client supports environment variables for advanced configuration. These are separate from the CLI flag environment variables (like NB_LOG_LEVEL) which are described in the CLI reference.

Setting environment variables

Environment variables must be set on the daemon process, not the CLI. When running NetBird as a system service, use --service-env to persist them:

# Set during install
sudo netbird service install --service-env NB_WG_KERNEL_DISABLED=true

# Or reconfigure a running service
sudo netbird service reconfigure --service-env NB_WG_KERNEL_DISABLED=true

# Multiple variables
sudo netbird service install --service-env NB_LOG_LEVEL=debug,NB_USE_LEGACY_ROUTING=true

When running in foreground mode, set them in the shell before starting:

NB_WG_KERNEL_DISABLED=true netbird up --foreground-mode

Networking and routing

VariablePlatformDescription
NB_USE_LEGACY_ROUTINGLinuxBypass the fwmark/ip-rule based routing and fall back to the simpler pre-0.26 routing method. Useful when exit nodes cause connectivity issues due to rp_filter or missing sysctl settings.
NB_SKIP_SOCKET_MARKLinuxBackward-compatibility alias for NB_USE_LEGACY_ROUTING.
NB_DISABLE_CUSTOM_ROUTINGAllRevert to the routing behavior from before exit node support was added. No exclusion routes or fwmark-based socket routing will be used; all dialers and listeners fall back to plain net.Dial/net.Listen. Routes with a prefix of /7 or larger (e.g. default routes, 0.0.0.0/0) will be rejected.
NB_ROUTE_PROTO_FLAGmacOS, BSDSet a custom route flag on routes the client adds to the routing table. Accepted values: 2 (RTF_PROTO2) or 3 (RTF_PROTO3); defaults to RTF_PROTO1. Not used on Linux (Linux uses netlink with its own protocol field).
NB_DISABLE_ROUTE_CACHEWindowsDisable the 2-second cache on Windows routing table lookups. The client reads the OS routing table (via Win32 API) when adding or removing routes; without the cache, each operation triggers a fresh read. Only needed for debugging route conflicts.

WireGuard and interface

VariablePlatformDescription
NB_WG_KERNEL_DISABLEDLinuxSkip loading the WireGuard kernel module and run entirely in userspace (wireguard-go). Use this when the kernel module is broken, missing, or conflicts with other software.
NB_WG_DEBUGAllSet to true to print low-level WireGuard protocol messages (handshakes, keypairs, timers) to the log. Very verbose.
NB_DISABLE_EBPF_WG_PROXYLinuxDisable the eBPF-based proxy that intercepts WireGuard UDP traffic and fall back to the classic UDP port proxy.
NB_USE_NETSTACK_MODEAllRun WireGuard on top of a userspace TCP/IP stack (gVisor netstack) instead of a TUN device. Required for environments without TUN support (e.g. unprivileged containers).
NB_NETSTACK_SKIP_PROXYAllWhen using netstack mode, do not start the built-in SOCKS5 proxy that exposes the WireGuard network to local applications.
NB_SOCKS5_LISTENER_PORTAllOverride the port the netstack SOCKS5 proxy listens on (default: 1080). Only relevant when netstack mode is active.

Firewall

VariablePlatformDescription
NB_SKIP_NFTABLES_CHECKLinuxDo not probe for nftables support at startup; go straight to the iptables backend. Useful on systems where nftables is installed but non-functional (e.g. missing kernel modules).
NB_NFTABLES_TABLELinuxName of the nftables table the client creates for ACL rules (default: netbird). Change this if the default name conflicts with existing firewall configuration.
NB_DISABLE_CONNTRACKAllTurn off the stateful connection tracker in the userspace packet filter. With conntrack enabled (default), inbound rules for return traffic sent by management are ignored because conntrack handles them automatically. Disabling conntrack means those inbound rules will be applied explicitly instead.
NB_DISABLE_USERSPACE_ROUTINGAllPrevent the userspace packet filter from forwarding packets between interfaces. Routing rules from the management server will be ignored when this is set.
NB_DISABLE_MSS_CLAMPINGAllStop the userspace filter from rewriting TCP SYN/SYN-ACK MSS options to fit the WireGuard MTU. May cause path-MTU black holes if disabled.
NB_FORCE_USERSPACE_ROUTERAllForce packet forwarding through the userspace router even when a native firewall backend (nftables/iptables) is available. Normally, the presence of a native backend causes the client to delegate route forwarding to the kernel. This flag overrides that: the native backend still handles ACL rules, but routed packets are forwarded by the userspace filter instead. On macOS, Windows, and netstack mode the userspace router is always used regardless of this setting.
NB_ENABLE_LOCAL_FORWARDINGAllAllow the userspace filter to forward packets destined for local addresses (not just routed subnets). Off by default to prevent unexpected local service exposure.
NB_ENABLE_NETSTACK_LOCAL_FORWARDINGAllSame as NB_ENABLE_LOCAL_FORWARDING but applies only when running in netstack mode. Takes precedence over the general setting when both are set.
NB_USPFILTER_LOG_BUFFERAllNumber of log messages the userspace packet filter can queue before dropping (default: 1000). Increase this on high-throughput nodes to avoid losing firewall log entries.

ICE and connectivity

VariablePlatformDescription
NB_FORCE_RELAYAllSkip direct connectivity entirely: the client will not start the ICE listener or attempt peer-to-peer connections. All traffic goes through relay servers. Useful for strict egress-only environments.
NB_ICE_KEEP_ALIVE_INTERVAL_SECAllHow often (in seconds) ICE sends keepalive packets to maintain NAT bindings and detect connection liveness (default: 4).
NB_ICE_DISCONNECTED_TIMEOUT_SECAllSeconds of silence before ICE marks a connection as disconnected and starts recovery (default: 6).
NB_ICE_FAILED_TIMEOUT_SECAllSeconds of silence before ICE gives up on the connection entirely and falls back to relay (default: 6).
NB_ICE_RELAY_ACCEPTANCE_MIN_WAIT_SECAllMinimum seconds ICE waits for a direct (P2P) candidate before accepting a relay candidate. Higher values give direct connections more time to succeed at the cost of slower initial connection (default: 2).
NB_ICE_MONITOR_PERIODAllInterval between ICE connection health checks that verify handshake freshness and trigger reconnection if needed (Go duration, default: 5m).
NB_ENABLE_EXPERIMENTAL_LAZY_CONNAllOpen WireGuard tunnels to peers only when traffic is detected, instead of connecting to all peers at startup. Same effect as the --enable-lazy-connection CLI flag.
NB_LAZY_CONN_INACTIVITY_THRESHOLDAllHow long a lazy connection can be idle before it is torn down (Go duration, default: 15m). Only applies when lazy connections are enabled.

DNS

VariablePlatformDescription
NB_DNS_FORWARDER_PORTAllOverride the port the internal DNS forwarder binds to for handling DNS routes received from clients (default: 22054). The forwarder is separate from the local resolver.
NB_SKIP_DNS_PROBEAllSkip the startup check that sends a test query to the local resolver to verify it is reachable. Set this if the probe causes delays (e.g. in air-gapped networks).
NB_UNCLEAN_SHUTDOWN_RESOLV_FILELinux, FreeBSDCustom file path to store a backup of /etc/resolv.conf before the client modifies it. Used to restore the original on next startup if the client crashed without cleaning up (default: <state-dir>/resolv.conf, i.e. /var/lib/netbird/resolv.conf on Linux, /var/db/netbird/resolv.conf on FreeBSD).

Connection retry

These control the exponential backoff when the client loses its connection to the management or signal server.

VariablePlatformDescription
NB_CONN_RETRY_INTERVAL_TIMEAllInitial wait time before the first reconnection attempt (Go duration, e.g. 5s).
NB_CONN_MAX_RETRY_INTERVAL_TIMEAllUpper bound on the backoff interval; retries will never wait longer than this (Go duration).
NB_CONN_MAX_RETRY_TIME_TIMEAllTotal time the client will keep retrying before giving up and reporting a persistent failure (Go duration). Note: the double _TIME suffix is intentional and matches the variable name in the source code.
NB_CONN_RETRY_MULTIPLIERAllFactor by which the retry interval grows after each attempt (float, e.g. 1.7).

SSH

VariablePlatformDescription
NB_DISABLE_SSH_CONFIGAllPrevent the client from writing NetBird peer entries into the system SSH config directory (/etc/ssh/ssh_config.d/99-netbird.conf on Unix, %PROGRAMDATA%\ssh\ssh_config.d\99-netbird.conf on Windows). By default, the client adds Host blocks so you can ssh peer-name without specifying the IP.
NB_FORCE_SSH_CONFIGAllWrite the SSH config entries even when the peer count exceeds the default limit of 200. Without this, the client skips SSH config generation for large networks to avoid slow file writes.

Relay

VariablePlatformDescription
NB_RELAY_HC_ATTEMPT_THRESHOLDAllNumber of consecutive failed WebSocket pings before the client considers a relay server unreachable and switches to a different one (default: 1).

Management

VariablePlatformDescription
NB_MANAGEMENT_GRPC_MAX_MSG_SIZEAllMaximum size (in bytes) of a single gRPC message from the management server. Increase this when the network map (peers, firewall rules, routes, DNS config) exceeds the default 4 MB gRPC limit.

Other

VariablePlatformDescription
NB_STATE_DIRAllOverride the directory where the client stores persistent state files (config, state.json, WireGuard keys). Defaults to /var/lib/netbird on Linux/macOS, /var/db/netbird on FreeBSD, %PROGRAMDATA%\Netbird on Windows.
NB_DNS_STATE_FILEAllOverride the path to the client state file (state.json). Despite the name, this is not DNS-specific: it stores all shutdown/recovery state including DNS settings, SSH config, routes, and auto-update progress. The default path is per-profile (e.g. /var/lib/netbird/state.json for the default profile). Setting this bypasses per-profile state isolation. Primarily used by the embedded client API (embed.Options.StatePath).
NB_ROSENPASS_LOG_LEVELAllLog level for the Rosenpass post-quantum key exchange subprocess. Accepted values: debug, info, warn, error (default: info). Separate from the main client log level.
NB_AUTO_UPDATE_DRY_RUNAllSet to true to run the auto-update check and download steps without actually replacing the binary. Useful for testing update infrastructure.
NB_PPROF_ADDRAllStart a Go pprof HTTP endpoint at this address (e.g. localhost:6060). For profiling CPU, memory, and goroutine usage in production.
NB_METRICS_PUSH_ENABLEDAllSet to true to enable periodic push of client telemetry (connection quality, peer counts) to a metrics server. Disabled by default.
NB_METRICS_INTERVALAllHow often to push metrics when enabled (Go duration, e.g. 60s).
NB_METRICS_SERVER_URLAllURL of the metrics collection server. Only needed when overriding the built-in default.
NB_METRICS_CONFIG_URLAllURL to fetch remote metrics configuration (which metrics to collect, sampling rates). Only needed when overriding the built-in default.