Netbird tunnel to self hosted server

Hi

I am trying to get the netbird tunnel connected to my self hosted server and am failing :frowning:

      services.netbird = {
        enable = true;
        tunnels = {
          home = {
            environment = {
              NB_MANAGEMENT_URL = "https://${loginServer}";
              NB_ADMIN_URL = "https://${loginServer}";
            };
          };
        };
      };

The above config on the client creates a config file but does not change the netbird config file to point to my self hosted server.

I can manually use netbird -m and it correctly takes me to my server to login.

Is the environment defn correct, as no errors are showing for this config.

Thanks

1 Like

This should be enough to start netbird (https://docs.netbird.io/how-to/installation#linux)

services.netbird.enable = true

The command to use your server (https://docs.netbird.io/how-to/installation#running-net-bird-with-a-setup-key)

netbird up --management-url "https://server" --admin-url "https://server"

Hey thanks for the response :slight_smile: … yes the latter command is what I use and it does work, but rather manual.

According to the nix module though we should be able to setup your command line options with ENV variables, so that they don’t need to be entered on the command line for every device.

            environment = {
              NB_MANAGEMENT_URL = "https://server";
              NB_ADMIN_URL = "https://server";
            };

I have added to the ENV in my config above but its just being ignored.

https://search.nixos.org/options?channel=24.05&show=services.netbird.tunnels.<name>.environment&from=0&size=50&sort=relevance&type=packages&query=services.netbird

Netbird only read those environment variables when you run netbird up

Really, oh wow, I didn’t know that, but are they saved in a config anywhere?

Looking at the configs used by netbird client they are still using the default netbird api urls.

1 Like

I encountered this post, which led me down a rabbit hole, but I eventually found a solution.

The systemd service is created with the environment set as intended. However, the Nix function does not generate the configuration files at /var/lib/netbird-<tunnel name>/config.json; this is handled by the Netbird client. To enable the Netbird CLI to utilize your systemd service, follow these steps:

  1. Modify the configuration at /var/lib/netbird-<tunnel name>/config.json by setting WgIface to <tunnel name> and adding it to the IFaceBlackList.

  2. Execute the CLI with the following command:

    netbird --daemon-addr unix:///var/run/netbird-<tunnel name>/sock -c /var/lib/netbird-<tunnel name>/config.json up
    

This approach ensures that the Netbird CLI operates in conjunction with the systemd service.