[GH-ISSUE #4322] OpenWrt: configuration may be lost #8904

Closed
opened 2026-08-05 01:19:58 -04:00 by saavagebueno · 10 comments
Owner

Originally created by @wehagy on GitHub (Aug 11, 2025).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/4322

Describe the problem

You may lose the configuration files after upgrading to any version later than 0.52.0.

To Reproduce

Steps to reproduce the behavior:

  1. Upgrade to any version after 0.52.0
  2. Reboot or flash new image.

Expected behavior

Avoid losing configuration files by using a persistent directory.

Are you using NetBird Cloud?

NetBird Cloud

NetBird version

0.54.0

Is any other VPN software installed?

no

Additional context

The version 0.52.0 introduced the profiles feature, changing the default configuration directory from /etc/netbird to /var/lib/netbird. In OpenWrt, this directory is a symbolic link to /tmp, which is a temporary directory. As a result, the configuration is lost after rebooting or flashing new image. As the maintainer of the netbird package in OpenWrt, I can easily change to another directory using the env NB_STATE_DIR, but I believe not everyone is aware of this option.

Have you tried these troubleshooting steps?

  • Reviewed client troubleshooting (if applicable)
  • Checked for newer NetBird versions
  • Searched for similar issues on GitHub (including closed ones)
  • Restarted the NetBird client
  • Disabled other VPN software
  • Checked firewall settings
Originally created by @wehagy on GitHub (Aug 11, 2025). Original GitHub issue: https://github.com/netbirdio/netbird/issues/4322 **Describe the problem** You may lose the configuration files after upgrading to any version later than `0.52.0`. **To Reproduce** Steps to reproduce the behavior: 1. Upgrade to any version after `0.52.0` 2. Reboot or flash new image. **Expected behavior** Avoid losing configuration files by using a persistent directory. **Are you using NetBird Cloud?** `NetBird Cloud` **NetBird version** `0.54.0` **Is any other VPN software installed?** `no` **Additional context** The version `0.52.0` introduced the profiles feature, changing the default configuration directory from `/etc/netbird` to `/var/lib/netbird`. In OpenWrt, this directory is a symbolic link to `/tmp`, which is a temporary directory. As a result, the configuration is lost after rebooting or flashing new image. As the maintainer of the `netbird` package in OpenWrt, I can easily change to another directory using the env `NB_STATE_DIR`, but I believe not everyone is aware of this option. **Have you tried these troubleshooting steps?** - [x] Reviewed [client troubleshooting](https://docs.netbird.io/how-to/troubleshooting-client) (if applicable) - [x] Checked for newer NetBird versions - [x] Searched for similar issues on GitHub (including closed ones) - [x] Restarted the NetBird client - [x] Disabled other VPN software - [x] Checked firewall settings
saavagebueno added the triage-needed label 2026-08-05 01:19:58 -04:00
Author
Owner

@MichaelUray commented on GitHub (Aug 20, 2025):

How to you handle it, that the NB_STATE_DIR environment variable gets set before the Netwird service starts during the bootup?
You probably could set it in /etc/init.d/netbird, but that file might get overwritten.

<!-- gh-comment-id:3204198604 --> @MichaelUray commented on GitHub (Aug 20, 2025): How to you handle it, that the `NB_STATE_DIR` environment variable gets set before the Netwird service starts during the bootup? You probably could set it in `/etc/init.d/netbird`, but that file might get overwritten.
Author
Owner

@MichaelUray commented on GitHub (Aug 20, 2025):

For testing I added the NB_STATE_DIR variable to the service in /etc/init.d/netbird:

export NB_STATE_DIR=/etc/netbird/state
cmd="/tmp/netbird "service" "run" "--log-level" "info" "--daemon-addr" "unix:///var/run/netbird.sock" "--log-file" "/var/log/netbird/client.log""

But then I noticed, that the files resolv.conf and state.json also ended up there and these files change regularily (eg. on each service restart, maybe more often):

root@fwr:~# ls -l /etc/netbird/state/
-rw-------    1 root     root            45 Aug 20 07:23 active_profile.json
-rw-------    1 root     root          1772 Aug 20 07:23 default.json
-rw-r--r--    1 root     root            47 Aug 20 08:21 resolv.conf
-rw-------    1 root     root           238 Aug 20 08:21 state.json

root@fwr:~# ls -l /var/lib/netbird
ls: /var/lib/netbird: No such file or directory

root@fwr:~# /etc/init.d/netbird stop
Stopping netbird......
Stopped

root@fwr:~# /etc/init.d/netbird start
Starting netbird

root@fwr:~# ls -l /etc/netbird/state/
-rw-------    1 root     root            45 Aug 20 07:23 active_profile.json
-rw-------    1 root     root          1772 Aug 20 07:23 default.json
-rw-r--r--    1 root     root            47 Aug 20 08:37 resolv.conf
-rw-------    1 root     root           238 Aug 20 08:37 state.json

I think the files resolv.conf and state.json should stay in /var/lib/netbird to not wear down the flash.

<!-- gh-comment-id:3204414905 --> @MichaelUray commented on GitHub (Aug 20, 2025): For testing I added the `NB_STATE_DIR` variable to the service in `/etc/init.d/netbird`: ``` export NB_STATE_DIR=/etc/netbird/state cmd="/tmp/netbird "service" "run" "--log-level" "info" "--daemon-addr" "unix:///var/run/netbird.sock" "--log-file" "/var/log/netbird/client.log"" ``` But then I noticed, that the files `resolv.conf` and `state.json` also ended up there and these files change regularily (eg. on each service restart, maybe more often): ``` root@fwr:~# ls -l /etc/netbird/state/ -rw------- 1 root root 45 Aug 20 07:23 active_profile.json -rw------- 1 root root 1772 Aug 20 07:23 default.json -rw-r--r-- 1 root root 47 Aug 20 08:21 resolv.conf -rw------- 1 root root 238 Aug 20 08:21 state.json root@fwr:~# ls -l /var/lib/netbird ls: /var/lib/netbird: No such file or directory root@fwr:~# /etc/init.d/netbird stop Stopping netbird...... Stopped root@fwr:~# /etc/init.d/netbird start Starting netbird root@fwr:~# ls -l /etc/netbird/state/ -rw------- 1 root root 45 Aug 20 07:23 active_profile.json -rw------- 1 root root 1772 Aug 20 07:23 default.json -rw-r--r-- 1 root root 47 Aug 20 08:37 resolv.conf -rw------- 1 root root 238 Aug 20 08:37 state.json ``` I think the files `resolv.conf` and `state.json` should stay in `/var/lib/netbird` to not wear down the flash.
Author
Owner

@nazarewk commented on GitHub (Aug 20, 2025):

I am not 100% sure how it works, but I have noticed persistence stanza in a Makefile of another NetBird package for OpenWRT 0bcbb3b8a7/netbird/Makefile (L44) , this could probably be reused to cover whole NB_STATE_DIR and/or selected dirs/files.

In my opinion: conceptually the move to /var/lib/netbird is the right move, because the profile (old config.json) file isn't really a static configuration file, but instead represents the current state and should be treated as such (going into state directories at /var/lib). NixOS was already remapping the location to /var/lib/netbird because of this.

<!-- gh-comment-id:3204690501 --> @nazarewk commented on GitHub (Aug 20, 2025): I am not 100% sure how it works, but I have noticed persistence stanza in a Makefile of another NetBird package for OpenWRT https://github.com/tbc0309/openwrt-netbird/blob/0bcbb3b8a77c8340a54b80d55eaff30a94c189b4/netbird/Makefile#L44 , this could probably be reused to cover whole `NB_STATE_DIR` and/or selected dirs/files. In my opinion: conceptually the move to `/var/lib/netbird` is the right move, because the profile (old `config.json`) file isn't really a static configuration file, but instead represents the current state and should be treated as such (going into state directories at `/var/lib`). NixOS was already remapping the location to `/var/lib/netbird` because of this.
Author
Owner

@MichaelUray commented on GitHub (Aug 20, 2025):

Maybe an option to run Netbird in a single configuration file mode would be a good idea, especially for server and router applications.
i guess the profiles are mainly usefull for user but not for machine applications.

<!-- gh-comment-id:3204983962 --> @MichaelUray commented on GitHub (Aug 20, 2025): Maybe an option to run Netbird in a single configuration file mode would be a good idea, especially for server and router applications. i guess the profiles are mainly usefull for user but not for machine applications.
Author
Owner

@nazarewk commented on GitHub (Aug 20, 2025):

Maybe an option to run Netbird in a single configuration file mode would be a good idea, especially for server and router applications.

We have somewhat addressed this in 0.53.0 by re-adding handling of $NB_CONFIG / --config as a location of the default profile. It will put one in /var/lib/netbird/ unless you explicitly tell it to use the /etc/netbird/config.json.


PS: @wehagy while we're at the "official" OpenWRT package, could you sync with the functionalities provided by https://github.com/tbc0309/openwrt-netbird/tree/main and maybe join efforts?

The features I'm particularly interested in are:

<!-- gh-comment-id:3205063471 --> @nazarewk commented on GitHub (Aug 20, 2025): > Maybe an option to run Netbird in a single configuration file mode would be a good idea, especially for server and router applications. We have somewhat addressed this in `0.53.0` by re-adding handling of `$NB_CONFIG` / `--config` as a location of the default profile. It will put one in `/var/lib/netbird/` unless you explicitly tell it to use the `/etc/netbird/config.json`. --- PS: @wehagy while we're at the "official" OpenWRT package, could you sync with the functionalities provided by https://github.com/tbc0309/openwrt-netbird/tree/main and maybe join efforts? The features I'm particularly interested in are: - [reading the `/etc/sysconfig/netbird`](https://github.com/tbc0309/openwrt-netbird/blob/0bcbb3b8a77c8340a54b80d55eaff30a94c189b4/netbird/files/netbird.init#L18C2-L18C95) (or other equivalent, maybe `/etc/default/netbird`) - automated update of the package after releases
Author
Owner

@MichaelUray commented on GitHub (Aug 21, 2025):

I also took the packages from tbc0309/openwrt-netbird.

So if I use the --config option like
netbird up --management-url https://netbird.example.com:443 --setup-key [KEY] --config /etc/netbird/config.json,
would it then still put the file resolv.conf and state.json into /var/lib/netbird/?
Because so far as I understand would it not be required to have these two files persistant and they might change in the operation, so it would be not good to have them on the flash memory in /etc/netbird/, but in the ram in /var/lib/netbird/.

Would it also apply these settings to the service which gets created to have them available after a reboot as well?

<!-- gh-comment-id:3209349936 --> @MichaelUray commented on GitHub (Aug 21, 2025): I also took the packages from [tbc0309/openwrt-netbird](https://github.com/tbc0309/openwrt-netbird/). So if I use the `--config` option like `netbird up --management-url https://netbird.example.com:443 --setup-key [KEY] --config /etc/netbird/config.json`, would it then still put the file `resolv.conf` and `state.json` into `/var/lib/netbird/`? Because so far as I understand would it not be required to have these two files persistant and they might change in the operation, so it would be not good to have them on the flash memory in `/etc/netbird/`, but in the ram in `/var/lib/netbird/`. Would it also apply these settings to the service which gets created to have them available after a reboot as well?
Author
Owner

@MichaelUray commented on GitHub (Aug 22, 2025):

It worked for me to use the following command to install the Netbird service on OpenWRT:

root@r1:~# netbird service install --service-env="NB_CONFIG=/etc/netbird/config.json"
NetBird service has been installed
root@r1:~# netbird service start
NetBird service has been started
root@r1:~# netbird up --management-url https://netbird.example.com:443 --setup-key [KEY]
Connected

All the required files were created in the right places,
the configuration in /etc/netbird/config.json (persistent) and
the other files in /var/lib/netbird as well as in /var/log/netbird (volatile):

root@r1:~# ls -l /etc/netbird/ /var/lib/netbird/
/etc/netbird/:
-rw-------    1 root     root          1766 Aug 22 08:39 config.json

/var/lib/netbird/:
-rw-------    1 root     root            45 Aug 22 08:39 active_profile.json
-rw-r--r--    1 root     root            58 Aug 22 08:39 resolv.conf
-rw-------    1 root     root           236 Aug 22 08:39 state.json

Even the profile file got created, not sure if that gets used with the NB_CONFIG argument, I assume not:

root@r1:~# cat /var/lib/netbird/active_profile.json
{
    "name": "default",
    "username": ""
}

So everything was fine, but after a reboot I did run into the problem, that the service did not start, since the directory /var/log/netbird did not exist.

root@r1:~# /etc/init.d/netbird start
Starting netbird
/etc/init.d/netbird: line 43: can't create /var/log/netbird/netbird.log: nonexistent directory
Unable to start, see /var/log/netbird/netbird.log and /var/log/netbird/netbird.err

I added [ -d /var/log/netbird ] || mkdir -p /var/log/netbird to /etc/init.d/netbird to create the required directory when the services gets started,

            echo "Starting $name"
            [ -d /var/log/netbird ] || mkdir -p /var/log/netbird

            $cmd >> "$stdout_log" 2>> "$stderr_log" &

but after a reboot the service was still not running and the directory still did not exist.

root@r1:~# ls -l /var/lib/netbird /var/log/netbird
ls: /var/lib/netbird: No such file or directory
ls: /var/log/netbird: No such file or directory

A manual start of the service created then the directory as expected.
I guess it gets started to early in the boot process when /var is not available.

root@r1:~# /etc/init.d/netbird start
Starting netbird
root@r1:~# ls -l /var/lib/netbird /var/log/netbird
/var/lib/netbird:
-rw-------    1 root     root            45 Aug 22 09:25 active_profile.json
-rw-r--r--    1 root     root            58 Aug 22 09:25 resolv.conf
-rw-------    1 root     root           236 Aug 22 09:25 state.json

/var/log/netbird:
-rw-r--r--    1 root     root          5900 Aug 22 09:25 client.log
-rw-r--r--    1 root     root             0 Aug 22 09:25 netbird.err
-rw-r--r--    1 root     root             0 Aug 22 09:25 netbird.log

As workaround I did add that to /etc/rc.local to restart the service at the end of the boot process.

root@r1:~# cat /etc/rc.local
/etc/init.d/netbird restart
exit 0

To check what happened I removed all the directories and re-installed everything:

root@r1:~# ls -l /var/lib/netbird /var/log/netbird
ls: /var/lib/netbird: No such file or directory
ls: /var/log/netbird: No such file or directory
root@r1:~# netbird service install --service-env="NB_CONFIG=/etc/netbird/config.json"
NetBird service has been installed

It looks the directory /var/log/netbird gets only created when the service gets installed:

root@r1:~# ls -l /var/lib/netbird /var/log/netbird
ls: /var/lib/netbird: No such file or directory
/var/log/netbird:
root@r1:~# netbird service start
NetBird service has been started

/var/lib/netbird gets created on each start of the Netbird process and I think the same should happen for /var/log/netbird.

root@r1:~# ls -l /var/lib/netbird /var/log/netbird
/var/lib/netbird:
-rw-------    1 root     root            45 Aug 22 09:37 active_profile.json
-rw-r--r--    1 root     root            58 Aug 22 09:37 resolv.conf
-rw-------    1 root     root           236 Aug 22 09:37 state.json

/var/log/netbird:
-rw-r--r--    1 root     root          5322 Aug 22 09:37 client.log
-rw-r--r--    1 root     root             0 Aug 22 09:37 netbird.err
-rw-r--r--    1 root     root             0 Aug 22 09:37 netbird.log
<!-- gh-comment-id:3213456500 --> @MichaelUray commented on GitHub (Aug 22, 2025): It worked for me to use the following command to install the Netbird service on OpenWRT: ``` root@r1:~# netbird service install --service-env="NB_CONFIG=/etc/netbird/config.json" NetBird service has been installed ``` ``` root@r1:~# netbird service start NetBird service has been started ``` ``` root@r1:~# netbird up --management-url https://netbird.example.com:443 --setup-key [KEY] Connected ``` All the required files were created in the right places, the configuration in `/etc/netbird/config.json` (persistent) and the other files in `/var/lib/netbird` as well as in `/var/log/netbird` (volatile): ``` root@r1:~# ls -l /etc/netbird/ /var/lib/netbird/ /etc/netbird/: -rw------- 1 root root 1766 Aug 22 08:39 config.json /var/lib/netbird/: -rw------- 1 root root 45 Aug 22 08:39 active_profile.json -rw-r--r-- 1 root root 58 Aug 22 08:39 resolv.conf -rw------- 1 root root 236 Aug 22 08:39 state.json ``` Even the profile file got created, not sure if that gets used with the `NB_CONFIG` argument, I assume not: ``` root@r1:~# cat /var/lib/netbird/active_profile.json { "name": "default", "username": "" } ``` So everything was fine, but after a reboot I did run into the problem, that the service did not start, since the directory `/var/log/netbird` did not exist. ``` root@r1:~# /etc/init.d/netbird start Starting netbird /etc/init.d/netbird: line 43: can't create /var/log/netbird/netbird.log: nonexistent directory Unable to start, see /var/log/netbird/netbird.log and /var/log/netbird/netbird.err ``` I added `[ -d /var/log/netbird ] || mkdir -p /var/log/netbird` to `/etc/init.d/netbird` to create the required directory when the services gets started, ``` echo "Starting $name" [ -d /var/log/netbird ] || mkdir -p /var/log/netbird $cmd >> "$stdout_log" 2>> "$stderr_log" & ``` but after a reboot the service was still not running and the directory still did not exist. ``` root@r1:~# ls -l /var/lib/netbird /var/log/netbird ls: /var/lib/netbird: No such file or directory ls: /var/log/netbird: No such file or directory ``` A manual start of the service created then the directory as expected. I guess it gets started to early in the boot process when `/var` is not available. ``` root@r1:~# /etc/init.d/netbird start Starting netbird ``` ``` root@r1:~# ls -l /var/lib/netbird /var/log/netbird /var/lib/netbird: -rw------- 1 root root 45 Aug 22 09:25 active_profile.json -rw-r--r-- 1 root root 58 Aug 22 09:25 resolv.conf -rw------- 1 root root 236 Aug 22 09:25 state.json /var/log/netbird: -rw-r--r-- 1 root root 5900 Aug 22 09:25 client.log -rw-r--r-- 1 root root 0 Aug 22 09:25 netbird.err -rw-r--r-- 1 root root 0 Aug 22 09:25 netbird.log ``` As workaround I did add that to `/etc/rc.local` to restart the service at the end of the boot process. ``` root@r1:~# cat /etc/rc.local /etc/init.d/netbird restart exit 0 ``` To check what happened I removed all the directories and re-installed everything: ``` root@r1:~# ls -l /var/lib/netbird /var/log/netbird ls: /var/lib/netbird: No such file or directory ls: /var/log/netbird: No such file or directory ``` ``` root@r1:~# netbird service install --service-env="NB_CONFIG=/etc/netbird/config.json" NetBird service has been installed ``` It looks the directory `/var/log/netbird` gets only created when the service gets installed: ``` root@r1:~# ls -l /var/lib/netbird /var/log/netbird ls: /var/lib/netbird: No such file or directory /var/log/netbird: ``` ``` root@r1:~# netbird service start NetBird service has been started ``` `/var/lib/netbird` gets created on each start of the Netbird process and I think the same should happen for `/var/log/netbird`. ``` root@r1:~# ls -l /var/lib/netbird /var/log/netbird /var/lib/netbird: -rw------- 1 root root 45 Aug 22 09:37 active_profile.json -rw-r--r-- 1 root root 58 Aug 22 09:37 resolv.conf -rw------- 1 root root 236 Aug 22 09:37 state.json /var/log/netbird: -rw-r--r-- 1 root root 5322 Aug 22 09:37 client.log -rw-r--r-- 1 root root 0 Aug 22 09:37 netbird.err -rw-r--r-- 1 root root 0 Aug 22 09:37 netbird.log ```
Author
Owner

@nazarewk commented on GitHub (Aug 22, 2025):

So if I use the --config option like
netbird up --management-url https://netbird.example.com:443 --setup-key [KEY] --config /etc/netbird/config.json,
would it then still put the file resolv.conf and state.json into /var/lib/netbird/?

No, only the config.json would be placed in /etc/netbird, the /var/lib/netbird/ does not hold any permanent state until you decide to add non-default profile.

<!-- gh-comment-id:3213565357 --> @nazarewk commented on GitHub (Aug 22, 2025): > So if I use the `--config` option like > `netbird up --management-url https://netbird.example.com:443 --setup-key [KEY] --config /etc/netbird/config.json`, > would it then still put the file `resolv.conf` and `state.json` into `/var/lib/netbird/`? No, only the `config.json` would be placed in `/etc/netbird`, the `/var/lib/netbird/` does not hold any permanent state until you decide to add non-default profile.
Author
Owner

@wehagy commented on GitHub (Aug 24, 2025):

How to you handle it, that the NB_STATE_DIR environment variable gets set before the Netwird service starts during the bootup? You probably could set it in /etc/init.d/netbird, but that file might get overwritten.

@MichaelUray, The file will only change if you installed via the package manager or flash a new OpenWrt image (expected behavior). Other modification methods are not supported (I'm a downstream maintainer, upstream is another story.).

Yep, I plan to modify /etc/init.d/netbird:

#!/bin/sh /etc/rc.common

START=99
STOP=10

USE_PROCD=1

start_service() {
	procd_open_instance
	procd_set_param command /usr/bin/netbird
	procd_set_param env NB_STATE_DIR="/root/.config/netbird" <<< SEE HERE
	procd_append_param command service run
	procd_set_param pidfile /var/run/netbird.pid
	procd_close_instance
}

This will follow the NetBird documentation, where state can be stored in /var/lib/netbird or in ${HOME}/.config/netbird.

We have somewhat addressed this in 0.53.0 by re-adding handling of $NB_CONFIG / --config as a location of the default profile. It will put one in /var/lib/netbird/ unless you explicitly tell it to use the /etc/netbird/config.json.

Or maybe I'll go this route: I'll probably keep the old behavior in OpenWrt 24.10, but add the new behavior for OpenWrt master.

I think the files resolv.conf and state.json should stay in /var/lib/netbird to not wear down the flash.

This is a good observation, but from what I see, state.json and resolv.conf only change in specific cases or when the service restarts. Normally netbird is fire-and-forget, and these two files might be important to persist.

root@OpenWrt:~# uptime
 17:57:41 up 6 days, 23:42,  load average: 0.00, 0.00, 0.00
root@OpenWrt:~# ls -la /root/.config/netbird/
drwxr-x---    2 root     root          1024 Aug 17 18:15 .
drwxr-x---    3 root     root          1024 Aug 14 03:47 ..
-rw-------    1 root     root            45 Aug 14 03:47 active_profile.json
-rw-------    1 root     root             7 Aug 14 03:48 active_profile.txt
-rw-------    1 root     root          1715 Aug 14 03:47 default.json
-rw-------    1 root     root           184 Aug 17 18:15 state.json
root@OpenWrt:~# service netbird restart
root@OpenWrt:~# ls -la /root/.config/netbird/
drwxr-x---    2 root     root          1024 Aug 24 17:59 .
drwxr-x---    3 root     root          1024 Aug 14 03:47 ..
-rw-------    1 root     root            45 Aug 14 03:47 active_profile.json
-rw-------    1 root     root             7 Aug 14 03:48 active_profile.txt
-rw-------    1 root     root          1715 Aug 14 03:47 default.json
-rw-------    1 root     root            67 Aug 24 17:59 state.json

I don't think this will be a problem, besides, netbird already backs up the original resolv.conf to /etc/resolv.conf.original.netbird.

root@router-personal:~# cat /etc/resolv.conf
# Generated by NetBird
# The original file can be restored from /etc/resolv.conf.original.netbird

search netbird.cloud private
nameserver 127.0.0.153

Also, note that my netbird doesn't save resolv.conf, I don't want netbird managing that file. It's managed by dnsmasq, which I point to netbird. To stop netbird managing resolv.conf, change "DisableDNS": false to true in your profile/config. The name is confusing, but this only disables DNS management, the netbird DNS server will still run.
Here (more or less, it's outdated, I need to write a wiki about it) you can see how I configure DNS: https://forum.openwrt.org/t/using-netbird-with-dnsmasq/218358/3?u=wehagy

Maybe an option to run Netbird in a single configuration file mode would be a good idea, especially for server and router applications.
i guess the profiles are mainly usefull for user but not for machine applications.

I think the same, but at the same time I don't want to diverge from upstream or lock users into a single config file without reason.


I am not 100% sure how it works, but I have noticed persistence stanza in a Makefile of another NetBird package for OpenWRT 0bcbb3b8a7/netbird/Makefile (L44) , this could probably be reused to cover whole NB_STATE_DIR and/or selected dirs/files.

@nazarewk, this is how I'm handling it, you can see my commit here fa2974f664. However, the Makefile you sent is broken, maybe not immediately, but it will fail as-is. For example, if you log in with the setup key and restart, the profile will be lost because it's saved under /var/... (a non‑persistent directory), and users are likely to be confused as to why.

In my opinion: conceptually the move to /var/lib/netbird is the right move, because the profile (old config.json) file isn't really a static configuration file, but instead represents the current state and should be treated as such (going into state directories at /var/lib). NixOS was already remapping the location to /var/lib/netbird because of this.

I don't know how NixOS handles /var, is it a persistent directory?
I ways treated the config|default.json as a config file, this file never has been changed by the netbird, just myself changed the file manually, but to be fair this file doesn't appear to be changed by hand...

PS: @wehagy while we're at the "official" OpenWRT package, could you sync with the functionalities provided by https://github.com/tbc0309/openwrt-netbird/tree/main and maybe join efforts?

This is a good idea, joining efforts is always better than working solo. However, I think the effort should go the other way, I need to follow OpenWrt rules to get a PR accepted. And even if something happens to me, OpenWrt will continue and others can carry on the work. I'm contributing to OpenWrt because netbird will likely get more visibility there(maybe?) than in a third‑party repo, and adding third‑party repos may be difficult for new users.

I'm happy to review and help anyone trying to get their PR accepted.

The features I'm particularly interested in are:

I've thought about this before, the OpenWrt way to handle configuration is using UCI, and I always thought the difference between netbird service run and netbird up made this less useful. In reality this is a big pain, netbird up is much more powerful. Some people shared their /etc/init.d/netbird with me and are changing config|default.json using sed, but that doesn't seem like the right approach.

Can you tell me more about the environments you're using or interested in?

  • automated update of the package after releases

This is tricky for several reasons. As I mentioned above, I must follow OpenWrt rules, one of them is that I build and test the package myself. NetBird moves fast, and sometimes there are multiple releases in a single day, which is one reason I delay new versions. Bugs can be introduced between releases, so I often wait longer before opening a PR. PR review is a manual, best‑effort community process, which adds more waiting time. Commits must land in the master branch first and then be backported to OpenWrt stable. I don't use OpenWrt stable myself, so I only backport there occasionally, I tried to find someone to test the backports, but everyone disappeared into the shadows.

netbird will not be updated for OpenWrt 23.05 because the latest netbird requires Golang 1.23+, while OpenWrt 23.05 Golang is stuck at 1.21.x, the maintainer won't backport newer Golang versions to stable. The same will eventually affect OpenWrt 24.10, if netbird requires Golang 1.24+, OpenWrt 24.10 Golang will remain at 1.23.x.


I really appreciate all your feedback and efforts.

<!-- gh-comment-id:3218489364 --> @wehagy commented on GitHub (Aug 24, 2025): > How to you handle it, that the `NB_STATE_DIR` environment variable gets set before the Netwird service starts during the bootup? You probably could set it in `/etc/init.d/netbird`, but that file might get overwritten. @MichaelUray, The file will only change if you installed via the package manager or flash a new OpenWrt image (expected behavior). Other modification methods are not supported (I'm a downstream maintainer, upstream is another story.). Yep, I plan to modify `/etc/init.d/netbird`: ```shell #!/bin/sh /etc/rc.common START=99 STOP=10 USE_PROCD=1 start_service() { procd_open_instance procd_set_param command /usr/bin/netbird procd_set_param env NB_STATE_DIR="/root/.config/netbird" <<< SEE HERE procd_append_param command service run procd_set_param pidfile /var/run/netbird.pid procd_close_instance } ``` This will follow the NetBird documentation, where state can be stored in `/var/lib/netbird` or in `${HOME}/.config/netbird`. > We have somewhat addressed this in `0.53.0` by re-adding handling of `$NB_CONFIG` / `--config` as a location of the default profile. It will put one in `/var/lib/netbird/` unless you explicitly tell it to use the `/etc/netbird/config.json`. Or maybe I'll go this route: I'll probably keep the old behavior in OpenWrt 24.10, but add the new behavior for OpenWrt master. > I think the files `resolv.conf` and `state.json` should stay in `/var/lib/netbird` to not wear down the flash. This is a good observation, but from what I see, `state.json` and `resolv.conf` only change in specific cases or when the service restarts. Normally `netbird` is fire-and-forget, and these two files might be important to persist. ```shell root@OpenWrt:~# uptime 17:57:41 up 6 days, 23:42, load average: 0.00, 0.00, 0.00 root@OpenWrt:~# ls -la /root/.config/netbird/ drwxr-x--- 2 root root 1024 Aug 17 18:15 . drwxr-x--- 3 root root 1024 Aug 14 03:47 .. -rw------- 1 root root 45 Aug 14 03:47 active_profile.json -rw------- 1 root root 7 Aug 14 03:48 active_profile.txt -rw------- 1 root root 1715 Aug 14 03:47 default.json -rw------- 1 root root 184 Aug 17 18:15 state.json root@OpenWrt:~# service netbird restart root@OpenWrt:~# ls -la /root/.config/netbird/ drwxr-x--- 2 root root 1024 Aug 24 17:59 . drwxr-x--- 3 root root 1024 Aug 14 03:47 .. -rw------- 1 root root 45 Aug 14 03:47 active_profile.json -rw------- 1 root root 7 Aug 14 03:48 active_profile.txt -rw------- 1 root root 1715 Aug 14 03:47 default.json -rw------- 1 root root 67 Aug 24 17:59 state.json ``` I don't think this will be a problem, besides, `netbird` already backs up the original `resolv.conf` to `/etc/resolv.conf.original.netbird`. ```shell root@router-personal:~# cat /etc/resolv.conf # Generated by NetBird # The original file can be restored from /etc/resolv.conf.original.netbird search netbird.cloud private nameserver 127.0.0.153 ``` Also, note that my `netbird` doesn't save `resolv.conf`, I don't want `netbird` managing that file. It's managed by `dnsmasq`, which I point to `netbird`. To stop `netbird` managing `resolv.conf`, change `"DisableDNS": false` to `true` in your profile/config. The name is confusing, but this only disables DNS management, the `netbird` DNS server will still run. Here (more or less, it's outdated, I need to write a wiki about it) you can see how I configure DNS: https://forum.openwrt.org/t/using-netbird-with-dnsmasq/218358/3?u=wehagy > Maybe an option to run Netbird in a single configuration file mode would be a good idea, especially for server and router applications. > i guess the profiles are mainly usefull for user but not for machine applications. I think the same, but at the same time I don't want to diverge from upstream or lock users into a single config file without reason. --- > I am not 100% sure how it works, but I have noticed persistence stanza in a Makefile of another NetBird package for OpenWRT https://github.com/tbc0309/openwrt-netbird/blob/0bcbb3b8a77c8340a54b80d55eaff30a94c189b4/netbird/Makefile#L44 , this could probably be reused to cover whole `NB_STATE_DIR` and/or selected dirs/files. @nazarewk, this is how I'm handling it, you can see my commit here https://github.com/wehagy/packages/commit/fa2974f664614c41491a0045bddc55a2bc6d4133. However, the Makefile you sent is broken, maybe not immediately, but it will fail as-is. For example, if you log in with the setup key and restart, the profile will be lost because it's saved under `/var/...` (a non‑persistent directory), and users are likely to be confused as to why. > In my opinion: conceptually the move to `/var/lib/netbird` is the right move, because the profile (old `config.json`) file isn't really a static configuration file, but instead represents the current state and should be treated as such (going into state directories at `/var/lib`). NixOS was already remapping the location to `/var/lib/netbird` because of this. I don't know how NixOS handles `/var`, is it a persistent directory? I ways treated the `config|default.json` as a config file, this file never has been changed by the `netbird`, just myself changed the file manually, but to be fair this file doesn't appear to be changed by hand... > PS: [@wehagy](https://github.com/wehagy) while we're at the "official" OpenWRT package, could you sync with the functionalities provided by https://github.com/tbc0309/openwrt-netbird/tree/main and maybe join efforts? This is a good idea, joining efforts is always better than working solo. However, I think the effort should go the other way, I need to follow OpenWrt rules to get a PR accepted. And even if something happens to me, OpenWrt will continue and others can carry on the work. I'm contributing to OpenWrt because `netbird` will likely get more visibility there(maybe?) than in a third‑party repo, and adding third‑party repos may be difficult for new users. I'm happy to review and help anyone trying to get their PR accepted. > The features I'm particularly interested in are: > >- [reading the `/etc/sysconfig/netbird`](https://github.com/tbc0309/openwrt-netbird/blob/0bcbb3b8a77c8340a54b80d55eaff30a94c189b4/netbird/files/netbird.init#L18C2-L18C95) (or other equivalent, maybe `/etc/default/netbird`) I've thought about this before, the OpenWrt way to handle configuration is using [UCI](https://openwrt.org/docs/techref/uci), and I always thought the difference between `netbird service run` and `netbird up` made this less useful. In reality this is a big pain, `netbird up` is much more powerful. Some people shared their `/etc/init.d/netbird` with me and are changing `config|default.json` using `sed`, but that doesn't seem like the right approach. Can you tell me more about the environments you're using or interested in? >- automated update of the package after releases This is tricky for several reasons. As I mentioned above, I must follow OpenWrt rules, one of them is that I build and test the package myself. NetBird moves fast, and sometimes there are multiple releases in a single day, which is one reason I delay new versions. Bugs can be introduced between releases, so I often wait longer before opening a PR. PR review is a manual, best‑effort community process, which adds more waiting time. Commits must land in the master branch first and then be backported to OpenWrt stable. I don't use OpenWrt stable myself, so I only backport there occasionally, I tried to find someone to test the backports, but everyone disappeared into the shadows. `netbird` will not be updated for OpenWrt 23.05 because the latest `netbird` requires Golang 1.23+, while OpenWrt 23.05 Golang is stuck at 1.21.x, the maintainer won't backport newer Golang versions to stable. The same will eventually affect OpenWrt 24.10, if `netbird` requires Golang 1.24+, OpenWrt 24.10 Golang will remain at 1.23.x. --- I really appreciate all your feedback and efforts.
Author
Owner

@wehagy commented on GitHub (Sep 10, 2025):

I have already decided how I'm going to handle this in the downstream repo, anyone interested can see the PR below:

<!-- gh-comment-id:3276728434 --> @wehagy commented on GitHub (Sep 10, 2025): I have already decided how I'm going to handle this in the downstream repo, anyone interested can see the PR below: - https://github.com/openwrt/packages/pull/27362
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#8904